forked from grafadruid/go-druid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_types_test.go
59 lines (55 loc) · 1.79 KB
/
task_types_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package druid
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTaskIngestionSpec(t *testing.T) {
var testData = []struct {
name string
options []TaskIngestionSpecOptions
expected *TaskIngestionSpec
}{
{
name: "druid reindex ingestion task",
options: []TaskIngestionSpecOptions{
SetTaskDataSource("telemetry-test"),
SetTaskDataDimensions(DimensionSet{{"id"}, {"kind"}, {"test"}}),
SetTaskDruidInputSource(
"telemetry-test",
time.Date(2023, 12, 12, 0, 0, 0, 0, time.UTC),
time.Date(2023, 12, 24, 0, 0, 0, 0, time.UTC),
),
SetTaskSchemaDiscovery(false),
SetTaskTimestampColumn("__time"),
SetTaskGranularitySpec("DAY", &QueryGranularitySpec{"none"}, true),
SetForceGuaranteedRollup(true),
},
expected: func() *TaskIngestionSpec {
out := NewTaskIngestionSpec()
out.Spec.DataSchema.DataSource = "telemetry-test"
out.Spec.DataSchema.DimensionsSpec = &DimensionsSpec{
Dimensions: DimensionSet{{"id"}, {"kind"}, {"test"}},
}
out.Spec.IOConfig.InputSource.Type = "druid"
out.Spec.IOConfig.InputSource.Datasource = "telemetry-test"
out.Spec.IOConfig.InputSource.Interval = "2023-12-12T00:00:00/2023-12-24T00:00:00"
out.Spec.DataSchema.TimeStampSpec.Column = "__time"
out.Spec.DataSchema.TimeStampSpec.Format = "auto"
out.Spec.DataSchema.GranularitySpec.SegmentGranularity = "DAY"
out.Spec.DataSchema.GranularitySpec.QueryGranularity = &QueryGranularitySpec{"none"}
out.Spec.DataSchema.GranularitySpec.Rollup = true
out.Spec.TuningConfig.ForceGuaranteedRollup = true
return out
}(),
},
}
for _, test := range testData {
t.Run(test.name, func(t *testing.T) {
actual := NewTaskIngestionSpec(
test.options...,
)
assert.Equal(t, test.expected, actual)
})
}
}