Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test to verify count for historical ingestions #65

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions quest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

const (
vus = "10"
duration = "5m"
schema_count = "20"
events_count = "10"
duration = "2m"
schema_count = "10"
events_count = "5"
)

func TestSmokeListLogStream(t *testing.T) {
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestSmokeLoadWithK6Stream(t *testing.T) {
cmd.Output()
}
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 60000)
QueryLogStreamCount(t, NewGlob.QueryClient, NewGlob.Stream, 20000)
AssertStreamSchema(t, NewGlob.QueryClient, NewGlob.Stream, SchemaBody)
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
}
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestSmokeLoad_TimePartition_WithK6Stream(t *testing.T) {
cmd.Output()
}
time.Sleep(60 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, time_partition_stream, 60000)
QueryLogStreamCount_Historical(t, NewGlob.QueryClient, time_partition_stream, 20000)
DeleteStream(t, NewGlob.QueryClient, time_partition_stream)
}

Expand Down Expand Up @@ -321,7 +321,7 @@ func TestSmokeLoad_CustomPartition_WithK6Stream(t *testing.T) {
cmd.Output()
}
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, custom_partition_stream, 60000)
QueryLogStreamCount(t, NewGlob.QueryClient, custom_partition_stream, 20000)
DeleteStream(t, NewGlob.QueryClient, custom_partition_stream)
}

Expand Down Expand Up @@ -353,7 +353,7 @@ func TestSmokeLoad_TimeAndCustomPartition_WithK6Stream(t *testing.T) {
cmd.Output()
}
time.Sleep(120 * time.Second)
QueryLogStreamCount(t, NewGlob.QueryClient, custom_partition_stream, 60000)
QueryLogStreamCount_Historical(t, NewGlob.QueryClient, custom_partition_stream, 20000)
DeleteStream(t, NewGlob.QueryClient, custom_partition_stream)
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/load_historical_batch_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const options = {

function current_time() {
let event = new Date();
return event.toUTCString();
event.setMonth(event.getMonth() - 1);
return event.toISOString();
}

function schemas() {
Expand Down
3 changes: 2 additions & 1 deletion scripts/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ export const options = {
contacts: {
executor: 'shared-iterations',
vus: 20,
iterations: 6000,
iterations: 2000,
},
},
};

function current_time() {
let event = new Date();
event.setMonth(event.getMonth() - 1);
return event.toISOString();
}

Expand Down
21 changes: 21 additions & 0 deletions test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,27 @@ func QueryLogStreamCount(t *testing.T, client HTTPClient, stream string, count u
require.Equalf(t, expected, body, "Query count incorrect; Expected %s, Actual %s", expected, body)
}

func QueryLogStreamCount_Historical(t *testing.T, client HTTPClient, stream string, count uint64) {
// Query last 30 minutes of data only
now := time.Now()
startTime := now.AddDate(0, 0, -32).Format(time.RFC3339Nano)
endTime := now.AddDate(0, 0, -30).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 QueryTwoLogStreamCount(t *testing.T, client HTTPClient, stream1 string, stream2 string, count uint64) {
// Query last 30 minutes of data only
endTime := time.Now().Add(time.Second).Format(time.RFC3339Nano)
Expand Down
Loading