fix(query): remove http.to and update test cases that used it
parent
c61646d0f4
commit
1b8ab3c2f2
2
go.mod
2
go.mod
|
|
@ -38,7 +38,7 @@ require (
|
|||
github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c // indirect
|
||||
github.com/hashicorp/raft v1.0.0 // indirect
|
||||
github.com/hashicorp/vault/api v1.0.2
|
||||
github.com/influxdata/flux v0.39.1-0.20190815180331-3137d2af4892
|
||||
github.com/influxdata/flux v0.39.1-0.20190815200827-04db64030428
|
||||
github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6
|
||||
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -205,8 +205,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
|
|||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/changelog v1.0.0 h1:RstJD6H48zLQj0GdE6E6k/6RPwtUjkyzIe/T1E/xuWU=
|
||||
github.com/influxdata/changelog v1.0.0/go.mod h1:uzpGWE/qehT8L426YuXwpMQub+a63vIINhIeEI9mnSM=
|
||||
github.com/influxdata/flux v0.39.1-0.20190815180331-3137d2af4892 h1:kIhmKfxranXtHJ9BhhGXy2ZmGVoKfm6D8OK+Ua01Kko=
|
||||
github.com/influxdata/flux v0.39.1-0.20190815180331-3137d2af4892/go.mod h1:pFWDX62wdE2DtMsXtYpYMRrTkZiIn3BYB5mQgCF57Yw=
|
||||
github.com/influxdata/flux v0.39.1-0.20190815200827-04db64030428 h1:a5xwMefG5eGa9dSxSIcrtUGZOOv+naEKUd1W7xGRkXE=
|
||||
github.com/influxdata/flux v0.39.1-0.20190815200827-04db64030428/go.mod h1:pFWDX62wdE2DtMsXtYpYMRrTkZiIn3BYB5mQgCF57Yw=
|
||||
github.com/influxdata/goreleaser v0.97.0-influx h1:jT5OrcW7WfS0e2QxfwmTBjhLvpIC9CDLRhNgZJyhj8s=
|
||||
github.com/influxdata/goreleaser v0.97.0-influx/go.mod h1:MnjA0e0Uq6ISqjG1WxxMAl+3VS1QYjILSWVnMYDxasE=
|
||||
github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6 h1:CFx+pP90q/qg3spoiZjf8donE4WpAdjeJfPOcoNqkWo=
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/influxdata/flux/interpreter"
|
||||
"github.com/influxdata/flux/plan"
|
||||
"github.com/influxdata/flux/semantic"
|
||||
"github.com/influxdata/flux/stdlib/http"
|
||||
"github.com/influxdata/flux/stdlib/influxdata/influxdb"
|
||||
"github.com/influxdata/flux/stdlib/kafka"
|
||||
"github.com/influxdata/flux/values"
|
||||
|
|
@ -164,8 +163,6 @@ func createToOpSpec(args flux.Arguments, a *flux.Administration) (flux.Operation
|
|||
Code: codes.Invalid,
|
||||
Msg: "specify at most one of url, brokers in the same `to` function",
|
||||
}
|
||||
case httpOK:
|
||||
s = &http.ToHTTPOpSpec{}
|
||||
case kafkaOK:
|
||||
s = &kafka.ToKafkaOpSpec{}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -318,14 +318,12 @@ func TestExecutor(t *testing.T) {
|
|||
// Some tests use t.Parallel, and the fake query service depends on unique scripts,
|
||||
// so format a new script with the test name in each test.
|
||||
const fmtTestScript = `
|
||||
import "http"
|
||||
|
||||
option task = {
|
||||
name: %q,
|
||||
every: 1m,
|
||||
}
|
||||
|
||||
from(bucket: "one") |> http.to(url: "http://example.com")`
|
||||
from(bucket: "one") |> to(bucket: "two", orgID: "0000000000000000")`
|
||||
|
||||
func testExecutorQuerySuccess(t *testing.T, fn createSysFn) {
|
||||
sys := fn()
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ func testTaskCRUD(t *testing.T, sys *System) {
|
|||
|
||||
// Update task: just update an option.
|
||||
newStatus = string(backend.TaskActive)
|
||||
newFlux = "import \"http\"\n\noption task = {\n\tname: \"task-changed #98\",\n\tcron: \"* * * * *\",\n\toffset: 5s,\n\tconcurrency: 100,\n}\n\nfrom(bucket: \"b\")\n\t|> http.to(url: \"http://example.com\")"
|
||||
newFlux = "option task = {\n\tname: \"task-changed #98\",\n\tcron: \"* * * * *\",\n\toffset: 5s,\n\tconcurrency: 100,\n}\n\nfrom(bucket: \"b\")\n\t|> to(bucket: \"two\", orgID: \"000000000000000\")"
|
||||
f, err = sys.TaskService.UpdateTask(authorizedCtx, origID, influxdb.TaskUpdate{Options: options.Options{Name: "task-changed #98"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -355,7 +355,7 @@ func testTaskCRUD(t *testing.T, sys *System) {
|
|||
|
||||
// Update task: switch to every.
|
||||
newStatus = string(backend.TaskActive)
|
||||
newFlux = "import \"http\"\n\noption task = {\n\tname: \"task-changed #98\",\n\tevery: 30s,\n\toffset: 5s,\n\tconcurrency: 100,\n}\n\nfrom(bucket: \"b\")\n\t|> http.to(url: \"http://example.com\")"
|
||||
newFlux = "option task = {\n\tname: \"task-changed #98\",\n\tevery: 30s,\n\toffset: 5s,\n\tconcurrency: 100,\n}\n\nfrom(bucket: \"b\")\n\t|> to(bucket: \"two\", orgID: \"000000000000000\")"
|
||||
f, err = sys.TaskService.UpdateTask(authorizedCtx, origID, influxdb.TaskUpdate{Options: options.Options{Every: *(options.MustParseDuration("30s"))}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -426,9 +426,7 @@ func testTaskCRUD(t *testing.T, sys *System) {
|
|||
//Retrieve the task again to ensure the options are now Every, without Cron or Offset
|
||||
func testTaskOptionsUpdateFull(t *testing.T, sys *System) {
|
||||
|
||||
script := `import "http"
|
||||
|
||||
option task = {
|
||||
script := `option task = {
|
||||
name: "task-Options-Update",
|
||||
cron: "* * * * *",
|
||||
concurrency: 100,
|
||||
|
|
@ -436,7 +434,7 @@ option task = {
|
|||
}
|
||||
|
||||
from(bucket: "b")
|
||||
|> http.to(url: "http://example.com")`
|
||||
|> to(bucket: "two", orgID: "000000000000000")`
|
||||
|
||||
cr := creds(t, sys)
|
||||
|
||||
|
|
@ -451,12 +449,10 @@ from(bucket: "b")
|
|||
t.Fatal(err)
|
||||
}
|
||||
t.Run("update task and delete offset", func(t *testing.T) {
|
||||
expectedFlux := `import "http"
|
||||
|
||||
option task = {name: "task-Options-Update", every: 10s, concurrency: 100}
|
||||
expectedFlux := `option task = {name: "task-Options-Update", every: 10s, concurrency: 100}
|
||||
|
||||
from(bucket: "b")
|
||||
|> http.to(url: "http://example.com")`
|
||||
|> to(bucket: "two", orgID: "000000000000000")`
|
||||
f, err := sys.TaskService.UpdateTask(authorizedCtx, task.ID, influxdb.TaskUpdate{Options: options.Options{Offset: &options.Duration{}, Every: *(options.MustParseDuration("10s"))}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -471,9 +467,7 @@ from(bucket: "b")
|
|||
}
|
||||
})
|
||||
t.Run("update task with different offset option", func(t *testing.T) {
|
||||
expectedFlux := `import "http"
|
||||
|
||||
option task = {
|
||||
expectedFlux := `option task = {
|
||||
name: "task-Options-Update",
|
||||
every: 10s,
|
||||
concurrency: 100,
|
||||
|
|
@ -481,7 +475,7 @@ option task = {
|
|||
}
|
||||
|
||||
from(bucket: "b")
|
||||
|> http.to(url: "http://example.com")`
|
||||
|> to(bucket: "two", orgID: "000000000000000")`
|
||||
f, err := sys.TaskService.UpdateTask(authorizedCtx, task.ID, influxdb.TaskUpdate{Options: options.Options{Offset: options.MustParseDuration("10s")}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -1450,9 +1444,7 @@ func creds(t *testing.T, s *System) TestCreds {
|
|||
}
|
||||
|
||||
const (
|
||||
scriptFmt = `import "http"
|
||||
|
||||
option task = {
|
||||
scriptFmt = `option task = {
|
||||
name: "task #%d",
|
||||
cron: "* * * * *",
|
||||
offset: 5s,
|
||||
|
|
@ -1460,11 +1452,9 @@ option task = {
|
|||
}
|
||||
|
||||
from(bucket:"b")
|
||||
|> http.to(url: "http://example.com")`
|
||||
|> to(bucket: "two", orgID: "000000000000000")`
|
||||
|
||||
scriptDifferentName = `import "http"
|
||||
|
||||
option task = {
|
||||
scriptDifferentName = `option task = {
|
||||
name: "task-changed #%d",
|
||||
cron: "* * * * *",
|
||||
offset: 5s,
|
||||
|
|
@ -1472,7 +1462,7 @@ option task = {
|
|||
}
|
||||
|
||||
from(bucket: "b")
|
||||
|> http.to(url: "http://example.com")`
|
||||
|> to(bucket: "two", orgID: "000000000000000")`
|
||||
)
|
||||
|
||||
func testTaskType(t *testing.T, sys *System) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue