@@ -33,6 +33,23 @@ const (
3333 sleepDuration = 2 * time .Second
3434)
3535
36+ func flogStreamFields () []string {
37+ return []string {
38+ "p_timestamp" ,
39+ "p_tags" ,
40+ "p_metadata" ,
41+ "host" ,
42+ "'user-identifier'" ,
43+ "datetime" ,
44+ "method" ,
45+ "request" ,
46+ "protocol" ,
47+ "status" ,
48+ "bytes" ,
49+ "referer" ,
50+ }
51+ }
52+
3653func readAsString (body io.Reader ) string {
3754 r , _ := io .ReadAll (body )
3855 return string (r )
@@ -123,6 +140,31 @@ func QueryTwoLogStreamCount(t *testing.T, client HTTPClient, stream1 string, str
123140 require .Equalf (t , expected , body , "Query count incorrect; Expected %s, Actual %s" , expected , body )
124141}
125142
143+ func AssertQueryOK (t * testing.T , client HTTPClient , query string , args ... any ) {
144+ // Query last 10 minutes of data only
145+ endTime := time .Now ().Add (time .Second ).Format (time .RFC3339Nano )
146+ startTime := time .Now ().Add (- 10 * time .Minute ).Format (time .RFC3339Nano )
147+
148+ var finalQuery string
149+ if len (args ) == 0 {
150+ finalQuery = query
151+ } else {
152+ finalQuery = fmt .Sprintf (query , args ... )
153+ }
154+
155+ queryJSON , _ := json .Marshal (map [string ]interface {}{
156+ "query" : finalQuery ,
157+ "startTime" : startTime ,
158+ "endTime" : endTime ,
159+ })
160+
161+ req , _ := client .NewRequest ("POST" , "query" , bytes .NewBuffer (queryJSON ))
162+ response , err := client .Do (req )
163+ require .NoErrorf (t , err , "Request failed: %s" , err )
164+ body := readAsString (response .Body )
165+ require .Equalf (t , 200 , response .StatusCode , "Server returned http code: %s and response: %s" , response .Status , body )
166+ }
167+
126168func AssertStreamSchema (t * testing.T , client HTTPClient , stream string , schema string ) {
127169 req , _ := client .NewRequest ("GET" , "logstream/" + stream + "/schema" , nil )
128170 response , err := client .Do (req )
0 commit comments