Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatsridhar95 committed Nov 5, 2024
1 parent d88fa41 commit 5c6666e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 54 deletions.
32 changes: 20 additions & 12 deletions tests/unittest/adjustTafChildrenPct/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ func TestMain(m *testing.M) {
os.Exit(testutil.UtilMain(m, cfg, nil))
}

/*
Should have the same size as the primary pool.
11/04/2024 14:54:52: hera.taf 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:53: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:53: hera.taf 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:54: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:54: hera.taf 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:55: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:55: hera.taf 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:56: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:56: hera.taf 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:57: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:57: hera.taf 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:58: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:58: hera.taf 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:54:59: hera 0 5 0 0 0 0 0 0 1 0 0
*/

func TestAdjustTafChildrenPct(t *testing.T) {

logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPct begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
Expand Down Expand Up @@ -77,26 +95,16 @@ func TestAdjustTafChildrenPct(t *testing.T) {
t.Fatalf("Expected TAF pool size: 10, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.taf")
if acpt != 5 {
t.Fatalf("Expected primary pool size: 10, Actual %d\n", acpt)
}

fmt.Println ("We now change max connections at runtime");
testutil.ModifyOpscfgParam (t, "hera.txt", "max_connections", "5")
//Wait for opsfcg change to take effect
time.Sleep(10 * time.Second)
time.Sleep(45 * time.Second)

acpt, _ = testutil.StatelogGetField(2, "hera.taf")

if acpt != 5 {
t.Fatalf("Expected TAF pool size: 5, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.taf")
if acpt != 5 {
t.Fatalf("Expected primary pool size: 5, Actual %d\n", acpt)
}

logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPct done -------------------------------------------------------------")
}
}
37 changes: 23 additions & 14 deletions tests/unittest/adjustTafChildrenPctModified/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ func TestMain(m *testing.M) {
os.Exit(testutil.UtilMain(m, cfg, nil))
}

/*
TAF pool should be 1/5th of the primary pool
11/04/2024 14:59:03: hera.taf 0 2 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:04: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:04: hera.taf 0 2 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:05: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:05: hera.taf 0 2 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:06: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:06: hera.taf 0 2 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:07: hera 0 10 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:07: hera.taf 0 2 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:08: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:08: hera.taf 0 1 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:09: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:09: hera.taf 0 1 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:10: hera 0 5 0 0 0 0 0 0 1 0 0
11/04/2024 14:59:10: hera.taf 0 1 0 0 0 0 0 0 1 0 0
*/

func TestAdjustTafChildrenPctModified(t *testing.T) {

logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPctModified begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
Expand Down Expand Up @@ -73,30 +92,20 @@ func TestAdjustTafChildrenPctModified(t *testing.T) {
t.Fatalf("Error reading state log: %s\n", err.Error())
}

if acpt != 3 {
if acpt != 2 {
t.Fatalf("Expected TAF pool size: 2, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.taf")
if acpt != 5 {
t.Fatalf("Expected primary pool size: 10, Actual %d\n", acpt)
}

fmt.Println ("We now change max connections at runtime");
testutil.ModifyOpscfgParam (t, "hera.txt", "max_connections", "5")
//Wait for opsfcg change to take effect
time.Sleep(10 * time.Second)
time.Sleep(45 * time.Second)

acpt, _ = testutil.StatelogGetField(2, "hera.taf")

if acpt != 5 {
if acpt != 1 {
t.Fatalf("Expected TAF pool size: 1, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.taf")
if acpt != 5 {
t.Fatalf("Expected primary pool size: 5, Actual %d\n", acpt)
}

logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPctModified done -------------------------------------------------------------")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func cfg() (map[string]string, map[string]string, testutil.WorkerType) {
appcfg["num_shards"] = "2"
appcfg["sharding_cfg_reload_interval"] = "0"

appcfg["opscfg.default.server.max_connections"] = "10"
appcfg["opscfg.default.server.max_connections"] = "20"

opscfg := make(map[string]string)
opscfg["opscfg.default.server.log_level"] = "5"
Expand All @@ -54,6 +54,23 @@ func TestMain(m *testing.M) {
os.Exit(testutil.UtilMain(m, cfg, nil))
}

/*
11/04/2024 16:42:44: hera.sh1 0 20 0 0 0 0 0 1 0 0 0
11/04/2024 16:42:44: hera.taf.sh1 0 4 0 0 0 0 0 1 0 0 0
11/04/2024 16:42:45: hera.sh0 0 19 0 1 0 0 0 1 0 0 0
11/04/2024 16:42:45: hera.taf.sh0 0 4 0 0 0 0 0 1 0 0 0
11/04/2024 16:42:45: hera.sh1 0 20 0 0 0 0 0 1 0 0 0
11/04/2024 16:42:45: hera.taf.sh1 0 4 0 0 0 0 0 1 0 0 0
11/04/2024 16:42:46: hera.sh0 0 5 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:46: hera.taf.sh0 0 1 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:46: hera.sh1 0 5 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:46: hera.taf.sh1 0 1 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:47: hera.sh0 0 5 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:47: hera.taf.sh0 0 1 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:47: hera.sh1 0 5 0 0 0 0 0 0 0 0 0
11/04/2024 16:42:47: hera.taf.sh1 0 1 0 0 0 0 0 0 0 0 0
*/

func TestAdjustTafChildrenPctWithSharding(t *testing.T) {
setupShardMap()
logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPctWithSharding begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
Expand All @@ -63,30 +80,20 @@ func TestAdjustTafChildrenPctWithSharding(t *testing.T) {
t.Fatalf("Error reading state log: %s\n", err.Error())
}

if acpt != 2 {
t.Fatalf("Expected TAF sh0 pool size: 2, Actual %d\n", acpt)
if acpt != 4 {
t.Fatalf("Expected TAF sh0 pool size: 4, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, "hera.taf.sh1")

if acpt != 2 {
t.Fatalf("Expected TAF sh1 pool size: 2, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.sh0")
if acpt != 10 {
t.Fatalf("Expected primary pool sh0 size: 10, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.sh1")
if acpt != 10 {
t.Fatalf("Expected primary pool sh1 size: 10, Actual %d\n", acpt)
if acpt != 4 {
t.Fatalf("Expected TAF sh1 pool size: 4, Actual %d\n", acpt)
}

fmt.Println ("We now change max connections at runtime");
testutil.ModifyOpscfgParam (t, "hera.txt", "max_connections", "5")
//Wait for opsfcg change to take effect
time.Sleep(10 * time.Second)
time.Sleep(45 * time.Second)

acpt, _ = testutil.StatelogGetField(2, "hera.taf.sh0")

Expand All @@ -100,15 +107,6 @@ func TestAdjustTafChildrenPctWithSharding(t *testing.T) {
t.Fatalf("Expected TAF sh1 pool size: 1, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.sh0")
if acpt != 5 {
t.Fatalf("Expected primary sh0 pool size: 5, Actual %d\n", acpt)
}

acpt, _ = testutil.StatelogGetField(2, " -v hera.sh1")
if acpt != 5 {
t.Fatalf("Expected primary sh1 pool size: 5, Actual %d\n", acpt)
}

logger.GetLogger().Log(logger.Debug, "TestAdjustTafChildrenPctWithSharding done -------------------------------------------------------------")
}
6 changes: 3 additions & 3 deletions tests/unittest/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ var (
func StatelogGetField(pos int, pattern ...string) (int, error) {
cmd := "/usr/bin/tail -n 1 state.log"
if len(pattern) > 0 {
cmd = fmt.Sprintf("/usr/bin/tail -n 1 state.log | grep '%s'", pattern[0])
// fmt.Println("cmd:", cmd)
cmd = fmt.Sprintf("/usr/bin/tac state.log | grep -m 1 -w '%s'", pattern[0])
fmt.Println("cmd:", cmd)
}
out, err := exec.Command("/bin/bash", "-c", cmd).Output()
if err != nil {
return -1, err
}
if len(out) != 99 {
if len(out) < 99 {
return -1, INCOMPLETE
}
c := 27 + 6*pos
Expand Down

0 comments on commit 5c6666e

Please sign in to comment.