Skip to content

Commit

Permalink
test(query): skip holt_winters_panic test
Browse files Browse the repository at this point in the history
added executor dependencies where needed
  • Loading branch information
nathanielc committed Aug 26, 2019
1 parent 0e4df01 commit 6303e2d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion query/bridges.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/influxdata/flux"
"github.com/influxdata/flux/csv"
"github.com/influxdata/flux/dependencies"
platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/kit/check"
"github.com/influxdata/influxdb/kit/tracing"
Expand Down Expand Up @@ -125,7 +126,7 @@ type REPLQuerier struct {
QueryService QueryService
}

func (q *REPLQuerier) Query(ctx context.Context, compiler flux.Compiler) (flux.ResultIterator, error) {
func (q *REPLQuerier) Query(ctx context.Context, deps dependencies.Interface, compiler flux.Compiler) (flux.ResultIterator, error) {
req := &Request{
Authorization: q.Authorization,
OrganizationID: q.OrganizationID,
Expand Down
1 change: 1 addition & 0 deletions query/control/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
ConcurrencyQuota: 1,
MemoryBytesQuotaPerQuery: 1024,
QueueSize: 1,
ExecutorDependencies: executetest.NewTestExecuteDependencies(),
}
)

Expand Down
4 changes: 3 additions & 1 deletion query/stdlib/influxdata/influxdb/to.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/influxdata/flux/dependencies"
"sort"
"time"

Expand Down Expand Up @@ -606,11 +607,12 @@ func writeTable(ctx context.Context, t *ToTransformation, tbl flux.Table) (err e
}
}

ctx, deps := context.Background(), dependencies.NewDefaultDependencies()
if spec.FieldFn.Fn == nil {
if fieldValues, err = defaultFieldMapping(er, i); err != nil {
return err
}
} else if fieldValues, err = t.fn.Eval(i, er); err != nil {
} else if fieldValues, err = t.fn.Eval(ctx, deps, i, er); err != nil {
return err
}

Expand Down
18 changes: 14 additions & 4 deletions query/stdlib/testing/end_to_end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"context"
"github.com/influxdata/flux/execute/executetest"
"strings"
"testing"

Expand Down Expand Up @@ -49,7 +50,8 @@ func runEndToEnd(t *testing.T, pkgs []*ast.Package) {
if reason, ok := itesting.FluxEndToEndSkipList[name]; ok {
t.Skip(reason)
}
testFlux(t, l, pkg)
c := lang.ASTCompiler{AST: pkg}
testFlux(t, l, pkg, c)
})
}
}
Expand All @@ -68,7 +70,8 @@ func benchEndToEnd(b *testing.B, pkgs []*ast.Package) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testFlux(b, l, pkg)
c := lang.ASTCompiler{AST: pkg}
testFlux(b, l, pkg, c)
}
})
}
Expand All @@ -95,7 +98,7 @@ func init() {
optionsAST = pkg.Files[0]
}

func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package, c flux.Compiler) {

// Query server to ensure write persists.

Expand All @@ -117,6 +120,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
Init: &ast.StringLiteral{Value: b.Name},
},
}

orgOpt := &ast.OptionStatement{
Assignment: &ast.VariableAssignment{
ID: &ast.Identifier{Name: "org"},
Expand All @@ -135,8 +139,14 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {

req := &query.Request{
OrganizationID: l.Org.ID,
Compiler: lang.ASTCompiler{AST: pkg},
Compiler: c,
}

program, err := c.Compile(context.Background())
if p, ok := program.(lang.DependenciesAwareProgram); ok {
p.SetExecutorDependencies(executetest.NewTestExecuteDependencies())
}

if r, err := l.FluxQueryService().Query(ctx, req); err != nil {
t.Fatal(err)
} else {
Expand Down
3 changes: 3 additions & 0 deletions storage/readservice/service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package readservice

import (
"github.com/influxdata/flux/dependencies"
platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/query"
"github.com/influxdata/influxdb/query/control"
Expand All @@ -25,6 +26,8 @@ func AddControllerConfigDependencies(
bucketSvc platform.BucketService,
orgSvc platform.OrganizationService,
) error {
cc.ExecutorDependencies[dependencies.InterpreterDepsKey] = dependencies.NewDefaultDependencies()

bucketLookupSvc := query.FromBucketService(bucketSvc)
orgLookupSvc := query.FromOrganizationService(orgSvc)
metrics := influxdb.NewMetrics(cc.MetricLabelKeys)
Expand Down
7 changes: 4 additions & 3 deletions task/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
package options

import (
"context"
"fmt"
"strings"
"time"

"github.com/influxdata/flux/parser"

"github.com/influxdata/flux/ast"

"github.com/influxdata/flux/dependencies"
"github.com/influxdata/flux"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
Expand Down Expand Up @@ -203,7 +203,8 @@ func FromScript(script string) (Options, error) {
return opt, err
}
durTypes := grabTaskOptionAST(fluxAST, optEvery, optOffset)
_, scope, err := flux.EvalAST(fluxAST)
ctx, deps := context.Background(), dependencies.NewDefaultDependencies()
_, scope, err := flux.EvalAST(ctx, deps, fluxAST)
if err != nil {
return opt, err
}
Expand Down

0 comments on commit 6303e2d

Please sign in to comment.