Skip to content

Commit 1bf3e41

Browse files
add tests for custom partition stream (#96)
--------- Co-authored-by: Nitish Tiwari <nitish@parseable.com>
1 parent 89ea23d commit 1bf3e41

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

quest_test.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ func TestLoadStream_StaticSchema_EventWithNewField(t *testing.T) {
189189
DeleteStream(t, NewGlob.QueryClient, staticSchemaStream)
190190
}
191191

192+
func TestCreateStream_WithCustomPartition_Success(t *testing.T) {
193+
customPartitionStream := NewGlob.Stream + "custompartition"
194+
customHeader := map[string]string{"X-P-Custom-Partition": "level"}
195+
CreateStreamWithHeader(t, NewGlob.QueryClient, customPartitionStream, customHeader)
196+
DeleteStream(t, NewGlob.QueryClient, customPartitionStream)
197+
}
198+
199+
func TestCreateStream_WithCustomPartition_Error(t *testing.T) {
200+
customPartitionStream := NewGlob.Stream + "custompartition"
201+
customHeader := map[string]string{"X-P-Custom-Partition": "level,os"}
202+
CreateStreamWithCustompartitionError(t, NewGlob.QueryClient, customPartitionStream, customHeader)
203+
}
204+
192205
func TestSmokeQueryTwoStreams(t *testing.T) {
193206
stream1 := NewGlob.Stream + "1"
194207
stream2 := NewGlob.Stream + "2"
@@ -600,7 +613,7 @@ func TestLoadHistoricalStreamBatchWithK6(t *testing.T) {
600613

601614
func TestLoadStreamBatchWithCustomPartitionWithK6(t *testing.T) {
602615
customPartitionStream := NewGlob.Stream + "custompartition"
603-
customHeader := map[string]string{"X-P-Custom-Partition": "level,os"}
616+
customHeader := map[string]string{"X-P-Custom-Partition": "level"}
604617
CreateStreamWithHeader(t, NewGlob.QueryClient, customPartitionStream, customHeader)
605618
if NewGlob.IngestorUrl.String() == "" {
606619
cmd := exec.Command("k6",
@@ -645,10 +658,10 @@ func TestLoadStreamBatchWithCustomPartitionWithK6(t *testing.T) {
645658
DeleteStream(t, NewGlob.QueryClient, customPartitionStream)
646659
}
647660

648-
func TestLoadStreamBatchWithTimeAndCustomPartitionWithK6(t *testing.T) {
661+
func TestLoadStreamBatchWithTimePartitionWithK6(t *testing.T) {
649662
if NewGlob.Mode == "load" {
650-
customPartitionStream := NewGlob.Stream + "timeandcustompartition"
651-
customHeader := map[string]string{"X-P-Custom-Partition": "level,os", "X-P-Time-Partition": "source_time"}
663+
customPartitionStream := NewGlob.Stream + "timepartition"
664+
customHeader := map[string]string{"X-P-Time-Partition": "source_time"}
652665
CreateStreamWithHeader(t, NewGlob.QueryClient, customPartitionStream, customHeader)
653666
if NewGlob.IngestorUrl.String() == "" {
654667
cmd := exec.Command("k6",

test_utils.go

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ func CreateStreamWithHeader(t *testing.T, client HTTPClient, stream string, head
8080
require.Equalf(t, 200, response.StatusCode, "Server returned http code: %s", response.Status)
8181
}
8282

83+
func CreateStreamWithCustompartitionError(t *testing.T, client HTTPClient, stream string, header map[string]string) {
84+
req, _ := client.NewRequest("PUT", "logstream/"+stream, nil)
85+
for k, v := range header {
86+
req.Header.Add(k, v)
87+
}
88+
response, _ := client.Do(req)
89+
require.Equalf(t, 500, response.StatusCode, "Server returned http code: %s", response.Status)
90+
}
91+
8392
func CreateStreamWithSchemaBody(t *testing.T, client HTTPClient, stream string, header map[string]string, schema_payload string) {
8493

8594
req, _ := client.NewRequest("PUT", "logstream/"+stream, bytes.NewBufferString(schema_payload))

0 commit comments

Comments
 (0)