Skip to content

Commit

Permalink
change for smoke test
Browse files Browse the repository at this point in the history
1. sleep from 1 to 2 mins
2. query duration from 10 to 30 mins
  • Loading branch information
nikhilsinhaparseable authored Jun 5, 2024
1 parent ea1d7df commit 3a8fc2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
6 changes: 3 additions & 3 deletions quest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestSmokeLoadWithK6Stream(t *testing.T) {
cmd.Run()
cmd.Output()
}
time.Sleep(60 * time.Second)
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 60000)
AssertStreamSchema(t, NewGlob.QueryClient, NewGlob.Stream, SchemaBody)
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestSmokeLoad_CustomPartition_WithK6Stream(t *testing.T) {
cmd.Run()
cmd.Output()
}
time.Sleep(60 * time.Second)
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, custom_partition_stream, 60000)
DeleteStream(t, NewGlob.QueryClient, custom_partition_stream)
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func TestSmokeLoad_TimeAndCustomPartition_WithK6Stream(t *testing.T) {
cmd.Run()
cmd.Output()
}
time.Sleep(60 * time.Second)
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, custom_partition_stream, 60000)
DeleteStream(t, NewGlob.QueryClient, custom_partition_stream)
}
Expand Down
32 changes: 6 additions & 26 deletions test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,29 +246,9 @@ func IngestOneEventForStaticSchemaStream_SameFieldsInLog(t *testing.T, client HT
}

func QueryLogStreamCount(t *testing.T, client HTTPClient, stream string, count uint64) {
// Query last 10 minutes of data only
// Query last 30 minutes of data only
endTime := time.Now().Add(time.Second).Format(time.RFC3339Nano)
startTime := time.Now().Add(-10 * time.Minute).Format(time.RFC3339Nano)

query := map[string]interface{}{
"query": "select count(*) as count from " + stream,
"startTime": startTime,
"endTime": endTime,
}
queryJSON, _ := json.Marshal(query)
req, _ := client.NewRequest("POST", "query", bytes.NewBuffer(queryJSON))
response, err := client.Do(req)
require.NoErrorf(t, err, "Request failed: %s", err)
body := readAsString(response.Body)
require.Equalf(t, 200, response.StatusCode, "Server returned http code: %s and response: %s", response.Status, body)
expected := fmt.Sprintf(`[{"count":%d}]`, count)
require.Equalf(t, expected, body, "Query count incorrect; Expected %s, Actual %s", expected, body)
}

func QueryLogStreamCount_WithTimePartition(t *testing.T, client HTTPClient, stream string, count uint64) {
// Query last 10 minutes of data only
endTime := "2024-05-17T10:00:00.000Z"
startTime := "2024-05-17T08:00:00.000Z"
startTime := time.Now().Add(-30 * time.Minute).Format(time.RFC3339Nano)

query := map[string]interface{}{
"query": "select count(*) as count from " + stream,
Expand All @@ -286,9 +266,9 @@ func QueryLogStreamCount_WithTimePartition(t *testing.T, client HTTPClient, stre
}

func QueryTwoLogStreamCount(t *testing.T, client HTTPClient, stream1 string, stream2 string, count uint64) {
// Query last 10 minutes of data only
// Query last 30 minutes of data only
endTime := time.Now().Add(time.Second).Format(time.RFC3339Nano)
startTime := time.Now().Add(-10 * time.Minute).Format(time.RFC3339Nano)
startTime := time.Now().Add(-30 * time.Minute).Format(time.RFC3339Nano)

query := map[string]interface{}{
"query": fmt.Sprintf("select sum(c) as count from (select count(*) as c from %s union all select count(*) as c from %s)", stream1, stream2),
Expand All @@ -306,9 +286,9 @@ func QueryTwoLogStreamCount(t *testing.T, client HTTPClient, stream1 string, str
}

func AssertQueryOK(t *testing.T, client HTTPClient, query string, args ...any) {
// Query last 10 minutes of data only
// Query last 30 minutes of data only
endTime := time.Now().Add(time.Second).Format(time.RFC3339Nano)
startTime := time.Now().Add(-10 * time.Minute).Format(time.RFC3339Nano)
startTime := time.Now().Add(-30 * time.Minute).Format(time.RFC3339Nano)

var finalQuery string
if len(args) == 0 {
Expand Down

0 comments on commit 3a8fc2c

Please sign in to comment.