Skip to content

Commit a9dc47b

Browse files
corrected test logic
1 parent cdd8cdf commit a9dc47b

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

quest_test.go

+16-22
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ func TestSmokeGetRetention(t *testing.T) {
403403
}
404404

405405
func TestActivateHotTier(t *testing.T) {
406+
CreateStream(t, NewGlob.QueryClient, NewGlob.Stream)
406407
activateHotTier(t)
408+
disableHotTier(t)
409+
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
407410
}
408411

409412
func TestHotTierGetsLogs(t *testing.T) {
@@ -419,31 +422,22 @@ func TestHotTierGetsLogsAfter(t *testing.T) {
419422
t.Skip("Skipping in standalone mode")
420423
}
421424

422-
logs := createAndIngest(t)
425+
// create a stream without hot tier
426+
createAndIngest(t)
427+
time.Sleep(2 * 60 * time.Second)
428+
prevCount := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 200)
429+
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
423430

431+
// create a second stream with hot tier
432+
createAndIngest(t)
424433
activateHotTier(t)
425-
time.Sleep(60 * 2 * time.Second) // wait for 2 minutes to allow hot tier to sync
426-
427-
// fetch the logs from hot tier
428-
req, _ := NewGlob.QueryClient.NewRequest("GET", "logstream/"+NewGlob.Stream+"/hottier", nil)
429-
response, err := NewGlob.QueryClient.Do(req)
430-
require.NoErrorf(t, err, "Fetching hot tier stream failed: %s", err)
431-
432-
// ascertain that they are in expected schema. prolly will be, just to be sure
433-
body, err := readJsonBody[StreamHotTier](response.Body)
434-
require.NoErrorf(t, err, "Hot tier response not in correct schema: %s", err)
435-
436-
// get total byte count of ingested logs
437-
size := 0
438-
for _, expectedlog := range logs {
439-
size = size + int(expectedlog.ByteCount)
440-
}
441-
442-
// ascertain that the ingested all the ingested logs are present in hot tier
443-
require.Equalf(t, size, "%d", *body.UsedSize, "Total size of ingested logs is %d GiB but hot tier contains %d GiB", size, body.UsedSize)
434+
time.Sleep(2 * 60 * time.Second) // wait 2 minutes for hot tier to sync
444435

436+
htCount := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 200)
445437
disableHotTier(t)
446438
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
439+
440+
require.Equalf(t, prevCount, htCount, "With hot tier disabled, the count was %s but with it, the count is %s", prevCount, htCount)
447441
}
448442

449443
// create stream, ingest data, query get count, set hot tier, wait for 2-3 mins, query again get count, both counts should match
@@ -453,12 +447,12 @@ func TestHotTierLogCount(t *testing.T) {
453447
}
454448

455449
createAndIngest(t)
456-
countBefore := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 50)
450+
countBefore := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 200)
457451

458452
activateHotTier(t)
459453
time.Sleep(60 * 2 * time.Second) // wait for 2 minutes to allow hot tier to sync
460454

461-
countAfter := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 50)
455+
countAfter := QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 200)
462456
require.Equalf(t, countBefore, countAfter, "Ingested %s, but hot tier contains only %s", countBefore, countAfter)
463457
}
464458

test_utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"io"
24-
"math"
2524
"os/exec"
2625
"strings"
2726
"testing"
@@ -76,8 +75,9 @@ func Sleep() {
7675
func CreateStream(t *testing.T, client HTTPClient, stream string) {
7776
req, _ := client.NewRequest("PUT", "logstream/"+stream, nil)
7877
response, err := client.Do(req)
78+
body := readAsString(response.Body)
7979
require.NoErrorf(t, err, "Request failed: %s", err)
80-
require.Equalf(t, 200, response.StatusCode, "Server returned http code: %s", response.Status)
80+
require.Equalf(t, 200, response.StatusCode, "Server returned http code: %s with response: %s", response.Status, body)
8181
}
8282

8383
func CreateStreamWithHeader(t *testing.T, client HTTPClient, stream string, header map[string]string) {
@@ -573,7 +573,7 @@ func checkAPIAccess(t *testing.T, client HTTPClient, stream string, role string)
573573

574574
func activateHotTier(t *testing.T) {
575575
payload := StreamHotTier{
576-
Size: fmt.Sprintf("%d", int64(20*math.Pow(1024, 3))), // set hot tier size to be 20 GB
576+
Size: "20 GiB", // set hot tier size to be 20 GB
577577
}
578578
json, _ := json.Marshal(payload)
579579

0 commit comments

Comments
 (0)