Skip to content

Commit

Permalink
Add a way to select the stream under test in system test runner
Browse files Browse the repository at this point in the history
This provides a means to select a stream to test by input type.

Closes elastic#186
  • Loading branch information
andrewkroh committed Nov 25, 2020
1 parent a1b5f26 commit fb7fda0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/testrunner/runners/system/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ func createPackageDatastream(
ds packages.DataStreamManifest,
c testConfig,
) ingestmanager.PackageDataStream {
streamInput := ds.Streams[0].Input
stream := ds.Streams[getDataStreamIndex(c.Input, ds)]
streamInput := stream.Input
r := ingestmanager.PackageDataStream{
Name: fmt.Sprintf("%s-%s", pkg.Name, ds.Name),
Namespace: "ep",
Expand Down Expand Up @@ -372,7 +373,7 @@ func createPackageDatastream(

// Add dataStream-level vars
dsVars := ingestmanager.Vars{}
for _, dsVar := range ds.Streams[0].Vars {
for _, dsVar := range stream.Vars {
val := dsVar.Default

cfgVar, exists := c.DataStream.Vars[dsVar.Name]
Expand Down Expand Up @@ -413,6 +414,17 @@ func createPackageDatastream(
return r
}

// getDataStreamIndex returns the index of the data stream whose input name
// matches. Otherwise it returns the 0.
func getDataStreamIndex(inputName string, ds packages.DataStreamManifest) int {
for i, s := range ds.Streams {
if s.Input == inputName {
return i
}
}
return 0
}

func deleteDataStreamDocs(esClient *es.Client, dataStream string) error {
body := strings.NewReader(`{ "query": { "match_all": {} } }`)
_, err := esClient.DeleteByQuery([]string{dataStream}, body)
Expand Down
1 change: 1 addition & 0 deletions internal/testrunner/runners/system/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
const configFileName = "config.yml"

type testConfig struct {
Input string `config:"input"`
Vars map[string]packages.VarValue `config:"vars"`
DataStream struct {
Vars map[string]packages.VarValue `config:"vars"`
Expand Down

0 comments on commit fb7fda0

Please sign in to comment.