From 04bff19cedf7ec05a2778ee9124c5b0ae51196a8 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 11 Apr 2024 11:19:32 +0300 Subject: [PATCH] Optimize AgentRequest test (2s->0.03s) Lowering the cfg cache TTL to 5ms instead of 1s was enough to get consistent results. --- agents/agentreq_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index 0acbbc56f..2ac8eb19c 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -2130,7 +2130,7 @@ func TestAgReqSetFieldsInCacheWithTimeOut(t *testing.T) { dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil) filterS := engine.NewFilterS(cfg, nil, dm) - cfg.CacheCfg().Partitions[utils.CacheUCH].TTL = time.Second + cfg.CacheCfg().Partitions[utils.CacheUCH].TTL = 5 * time.Millisecond engine.Cache = engine.NewCacheS(cfg, dm, nil) agReq := NewAgentRequest(nil, nil, nil, nil, nil, nil, "cgrates.org", "", filterS, nil) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.AccountField, PathSlice: []string{utils.AccountField}}, utils.NewLeafNode("1001")) @@ -2166,7 +2166,7 @@ func TestAgReqSetFieldsInCacheWithTimeOut(t *testing.T) { t.Error(err) } // give enough time to Cache to remove ttl the *uch - time.Sleep(2 * time.Second) + time.Sleep(6 * time.Millisecond) if _, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Tenant}); err == nil || err != utils.ErrNotFound { t.Error(err) }