-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
test: add fluxtest harness #21074
Merged
Merged
test: add fluxtest harness #21074
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ab03eca
test: first pass at backporting flux-test harness
danxmoran adc3d63
test: add script to run flux tests
danxmoran d26687e
test: add config toggle to enable test capabilities in Flux controller
danxmoran 0ea1767
test: explicitly set index type to fix many tests
danxmoran 6472f2b
refactor: remove config for enabling flux testing options
danxmoran f9ea07d
fix: remove old parameter from test
danxmoran 259bf49
refactor: get all tests but 1 working, remove init hack
danxmoran fd736d5
feat(flux): add MergeFiltersRule to pass fluxtest
danxmoran 1ce05fe
refactor: replace existing 'from' rewrite logic with a planner rule
danxmoran 92ac2bb
build: bump existing Dockerfiles to go 1.15
danxmoran 5634574
build: add flux tests to CI
danxmoran 75dfeb5
refactor: allow for overriding tcp.Mux logger
danxmoran 474e7aa
test: run flux e2e tests against both inmem and tsi1 indexes
danxmoran b2522b7
chore: fix formatting
danxmoran c2bed12
build: upgrade to Flux v0.110.0
danxmoran 72583b5
build: consolidate Dockerfiles, upgrade ubuntu and python
danxmoran bbd4c88
refactor: clean up redundant code
danxmoran 25b81bc
chore: add some comments on new methods
danxmoran 7c9e948
test: fix test case after deleting struct
danxmoran 3f31972
build: delete unused Dockerfile
danxmoran 0882048
build: clean up functions in test script
danxmoran 4f4c355
build: upgrade to latest Flux
danxmoran f9416ff
chore: update CHANGELOG
danxmoran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
readonly GO=${GO:-go} | ||
|
||
log() { | ||
local now | ||
now=$(date '+%Y/%m/%d %H:%M:%S') | ||
echo "[${now}]" "$@" | ||
} | ||
|
||
determine_flux_revision() { | ||
local version revision | ||
version=$("$GO" list -m -f '{{.Version}}' github.com/influxdata/flux) | ||
revision=$(printf "%s" "${version}" | cut -d- -f 3) | ||
if [[ ${revision} != "" ]]; then | ||
printf "%s\n" "${revision}" | ||
else | ||
printf "%s\n" "${version}" | ||
fi | ||
} | ||
|
||
download_flux_archive() { | ||
local revision | ||
revision=$(determine_flux_revision) | ||
log "Downloading flux archive (${revision})..." | ||
curl -sLo flux.zip "https://github.com/influxdata/flux/archive/${revision}.zip" | ||
} | ||
|
||
build_test_harness() { | ||
log "Building test harness..." | ||
"$GO" build -o fluxtest ./internal/cmd/fluxtest-harness-influxdb | ||
} | ||
|
||
run_integration_tests() { | ||
log "Running flux integration tests..." | ||
./fluxtest -v -p flux.zip | ||
log "Running influxdb integration tests..." | ||
./fluxtest -v -p flux/stdlib | ||
} | ||
|
||
cleanup() { | ||
rm -f flux.zip fluxtest | ||
} | ||
|
||
main() { | ||
build_test_harness | ||
download_flux_archive | ||
run_integration_tests | ||
cleanup | ||
} | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
// Package builtin ensures all packages related to Flux built-ins are imported and initialized. | ||
// Package init ensures all packages related to Flux built-ins are imported and initialized. | ||
// This should only be imported from main or test packages. | ||
// It is a mistake to import it from any other package. | ||
package builtin | ||
// | ||
// NOTE: This is a superset-wrapper of Flux's built-in initialization logic. | ||
// It also ensures V1-specific flux builtins are initialized. | ||
package init | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/influxdata/flux/runtime" | ||
_ "github.com/influxdata/flux/stdlib" | ||
_ "github.com/influxdata/influxdb/flux/stdlib" | ||
) | ||
|
||
var once sync.Once | ||
|
||
// Initialize ensures all Flux builtins are configured and should be called | ||
// prior to using the Flux runtime. Initialize is safe to call concurrently | ||
// and is idempotent. | ||
func Initialize() { | ||
once.Do(func() { | ||
runtime.FinalizeBuiltIns() | ||
}) | ||
runtime.FinalizeBuiltIns() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// The init/static package can be imported in test cases and other uses | ||
// cases where it is okay to always initialize flux. | ||
package static | ||
|
||
import fluxinit "github.com/influxdata/influxdb/flux/init" | ||
|
||
func init() { | ||
fluxinit.Initialize() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package influxdb_test | ||
|
||
import "csv" | ||
import "testing" | ||
import "testing/expect" | ||
|
||
option now = () => (2030-01-01T00:00:00Z) | ||
|
||
input = "#datatype,string,long,dateTime:RFC3339,string,string,string,double | ||
#group,false,false,false,true,true,true,false | ||
#default,_result,,,,,, | ||
,result,table,_time,_measurement,host,_field,_value | ||
,,0,2018-05-22T19:53:26Z,system,host.local,load1,1.83 | ||
,,0,2018-05-22T19:53:36Z,system,host.local,load1,1.63 | ||
,,1,2018-05-22T19:53:26Z,system,host.local,load3,1.72 | ||
,,2,2018-05-22T19:53:26Z,system,host.local,load4,1.77 | ||
,,2,2018-05-22T19:53:36Z,system,host.local,load4,1.78 | ||
,,2,2018-05-22T19:53:46Z,system,host.local,load4,1.77 | ||
" | ||
|
||
testcase filter { | ||
expect.planner(rules: [ | ||
"influxdata/influxdb.FromStorageRule": 1, | ||
"PushDownRangeRule": 1, | ||
"PushDownFilterRule": 1, | ||
]) | ||
|
||
want = csv.from(csv: "#datatype,string,long,dateTime:RFC3339,string,string,string,double | ||
#group,false,false,false,true,true,true,false | ||
#default,_result,,,,,, | ||
,result,table,_time,_measurement,host,_field,_value | ||
,,0,2018-05-22T19:53:26Z,system,host.local,load1,1.83 | ||
,,0,2018-05-22T19:53:36Z,system,host.local,load1,1.63 | ||
") | ||
|
||
got = testing.loadStorage(csv: input) | ||
|> range(start: -100y) | ||
|> filter(fn: (r) => r._measurement == "system" and r._field == "load1") | ||
|> drop(columns: ["_start", "_stop"]) | ||
testing.diff(want, got) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
package influxdb_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/influxdata/flux" | ||
"github.com/influxdata/flux/plan" | ||
"github.com/influxdata/flux/plan/plantest" | ||
"github.com/influxdata/flux/stdlib/influxdata/influxdb" | ||
"github.com/influxdata/flux/stdlib/universe" | ||
qinfluxdb "github.com/influxdata/influxdb/flux/stdlib/influxdata/influxdb" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFromValidation(t *testing.T) { | ||
spec := plantest.PlanSpec{ | ||
// from |> group (cannot query an infinite time range) | ||
Nodes: []plan.Node{ | ||
plan.CreateLogicalNode("from", &influxdb.FromProcedureSpec{ | ||
Bucket: influxdb.NameOrID{Name: "my-bucket"}, | ||
}), | ||
plan.CreatePhysicalNode("group", &universe.GroupProcedureSpec{ | ||
GroupMode: flux.GroupModeBy, | ||
GroupKeys: []string{"_measurement", "_field"}, | ||
}), | ||
}, | ||
Edges: [][2]int{ | ||
{0, 1}, | ||
}, | ||
} | ||
|
||
ps := plantest.CreatePlanSpec(&spec) | ||
pp := plan.NewPhysicalPlanner(plan.OnlyPhysicalRules( | ||
qinfluxdb.FromStorageRule{}, | ||
qinfluxdb.PushDownRangeRule{}, | ||
qinfluxdb.PushDownFilterRule{}, | ||
qinfluxdb.PushDownGroupRule{}, | ||
)) | ||
_, err := pp.Plan(context.Background(), ps) | ||
require.Error(t, err, "Expected query with no call to range to fail physical planning") | ||
want := `cannot submit unbounded read to "my-bucket"; try bounding 'from' with a call to 'range'` | ||
require.Equal(t, want, err.Error()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was performing the same rewrite logic as the new
FromStorageRule
pushdown. I thought it'd be good to refactor into a 1:1 match with the 2.x code, so future back-/forward-ports have fewer differences to think through.