Refactoring executor tests' usage of IDs (tasks)

pull/10616/head
Leonardo Di Donato 2018-07-31 01:34:03 +02:00 committed by Leonardo Di Donato
parent d2e764200e
commit b67d3123e2
1 changed files with 17 additions and 8 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/influxdata/platform/query/values"
"github.com/influxdata/platform/task/backend"
"github.com/influxdata/platform/task/backend/executor"
platformtesting "github.com/influxdata/platform/testing"
"go.uber.org/zap"
)
@ -225,13 +226,15 @@ const testScript = `option task = {
from(bucket: "one") |> toHTTP(url: "http://example.com")`
func testExecutorQuerySuccess(t *testing.T, fn createSysFn) {
var orgID = platformtesting.MustIDFromString(t, "aaaaaaaaaaaaaaaa")
var userID = platformtesting.MustIDFromString(t, "baaaaaaaaaaaaaab")
sys := fn()
t.Run(sys.name+"/QuerySuccess", func(t *testing.T) {
tid, err := sys.st.CreateTask(context.Background(), platform.ID("org"), platform.ID("user"), testScript)
tid, err := sys.st.CreateTask(context.Background(), orgID, userID, testScript)
if err != nil {
t.Fatal(err)
}
qr := backend.QueuedRun{TaskID: tid, RunID: platform.ID{1}, Now: 123}
qr := backend.QueuedRun{TaskID: *tid, RunID: platform.ID(1), Now: 123}
rp, err := sys.ex.Execute(context.Background(), qr)
if err != nil {
t.Fatal(err)
@ -275,13 +278,15 @@ func testExecutorQuerySuccess(t *testing.T, fn createSysFn) {
}
func testExecutorQueryFailure(t *testing.T, fn createSysFn) {
var orgID = platformtesting.MustIDFromString(t, "aaaaaaaaaaaaaaaa")
var userID = platformtesting.MustIDFromString(t, "baaaaaaaaaaaaaab")
sys := fn()
t.Run(sys.name+"/QueryFail", func(t *testing.T) {
tid, err := sys.st.CreateTask(context.Background(), platform.ID("org"), platform.ID("user"), testScript)
tid, err := sys.st.CreateTask(context.Background(), orgID, userID, testScript)
if err != nil {
t.Fatal(err)
}
qr := backend.QueuedRun{TaskID: tid, RunID: platform.ID{1}, Now: 123}
qr := backend.QueuedRun{TaskID: *tid, RunID: platform.ID(1), Now: 123}
rp, err := sys.ex.Execute(context.Background(), qr)
if err != nil {
t.Fatal(err)
@ -301,13 +306,15 @@ func testExecutorQueryFailure(t *testing.T, fn createSysFn) {
}
func testExecutorPromiseCancel(t *testing.T, fn createSysFn) {
var orgID = platformtesting.MustIDFromString(t, "aaaaaaaaaaaaaaaa")
var userID = platformtesting.MustIDFromString(t, "baaaaaaaaaaaaaab")
sys := fn()
t.Run(sys.name+"/PromiseCancel", func(t *testing.T) {
tid, err := sys.st.CreateTask(context.Background(), platform.ID("org"), platform.ID("user"), testScript)
tid, err := sys.st.CreateTask(context.Background(), orgID, userID, testScript)
if err != nil {
t.Fatal(err)
}
qr := backend.QueuedRun{TaskID: tid, RunID: platform.ID{1}, Now: 123}
qr := backend.QueuedRun{TaskID: *tid, RunID: platform.ID(1), Now: 123}
rp, err := sys.ex.Execute(context.Background(), qr)
if err != nil {
t.Fatal(err)
@ -326,13 +333,15 @@ func testExecutorPromiseCancel(t *testing.T, fn createSysFn) {
}
func testExecutorServiceError(t *testing.T, fn createSysFn) {
var orgID = platformtesting.MustIDFromString(t, "aaaaaaaaaaaaaaaa")
var userID = platformtesting.MustIDFromString(t, "baaaaaaaaaaaaaab")
sys := fn()
t.Run(sys.name+"/ServiceError", func(t *testing.T) {
tid, err := sys.st.CreateTask(context.Background(), platform.ID("org"), platform.ID("user"), testScript)
tid, err := sys.st.CreateTask(context.Background(), orgID, userID, testScript)
if err != nil {
t.Fatal(err)
}
qr := backend.QueuedRun{TaskID: tid, RunID: platform.ID{1}, Now: 123}
qr := backend.QueuedRun{TaskID: *tid, RunID: platform.ID(1), Now: 123}
var forced = errors.New("forced")
sys.svc.FailNextQuery(forced)