Skip to content
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

Add negative e2e tests for workflowbackend #7414

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions tests/e2e/wf_backend/workflow_invalid_backend_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//go:build e2e
// +build e2e

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package wf_backend_e2e

import (
"os"
"testing"

"github.com/dapr/dapr/tests/e2e/utils"
kube "github.com/dapr/dapr/tests/platforms/kubernetes"
"github.com/dapr/dapr/tests/runner"
)

var (
tr *runner.TestRunner
appNamePrefix = "workflowsapp"
)

func TestMain(m *testing.M) {
utils.SetupLogs("workflowtestdapr")
utils.InitHTTPClient(true)

// This test can be run outside of Kubernetes too
// Run the workflow e2e app using, for example, the Dapr CLI:
// ASPNETCORE_URLS=http://*:3000 dapr run --app-id workflowsapp --resources-path ./resources -- dotnet run
// Then run this test with the env var "WORKFLOW_APP_ENDPOINT" pointing to the address of the app. For example:
// WORKFLOW_APP_ENDPOINT=http://localhost:3000 DAPR_E2E_TEST="workflows" make test-clean test-e2e-all |& tee test.log
if os.Getenv("WORKFLOW_APP_ENDPOINT") == "" {
validateInvalidWorkflowBackendSetup(m)

// Exit with 0 to indicate success
os.Exit(0)
} else {
os.Exit(m.Run())
}
}

func getTestApp(backend string) kube.AppDescription {
testApps := kube.AppDescription{
AppName: appNamePrefix + "-" + backend,
DaprEnabled: true,
ImageName: "e2e-workflowsapp",
Replicas: 1,
IngressEnabled: true,
IngressPort: 3000,
DaprMemoryLimit: "200Mi",
DaprMemoryRequest: "100Mi",
AppMemoryLimit: "200Mi",
AppMemoryRequest: "100Mi",
AppPort: -1,
DebugLoggingEnabled: true,
}

return testApps
}

func validateInvalidWorkflowBackendSetup(m *testing.M) {
var testApps []kube.AppDescription
testApps = append(testApps, getTestApp("multibackend"))
testApps = append(testApps, getTestApp("invalidbackend"))
comps := []kube.ComponentDescription{
{
Name: "sqlitebackend2",
TypeName: "workflowbackend.sqlite",
MetaData: map[string]kube.MetadataValue{
"connectionString": {Raw: `""`},
},
Scopes: []string{appNamePrefix + "-multibackend"},
},
{
Name: "actorbackend",
TypeName: "workflowbackend.actor",
Scopes: []string{appNamePrefix + "-multibackend"},
},
{
Name: "invalidbackend",
TypeName: "workflowbackend.invalidbackend",
MetaData: map[string]kube.MetadataValue{
"connectionString": {Raw: `""`},
},
Scopes: []string{appNamePrefix + "-invalidbackend"},
},
}

tr = runner.NewTestRunner("workflowsapp-multibackend", testApps, comps, nil)
exitCode := tr.Start(m)

// If there are multiple workflow backend is defined, then app should not start
if exitCode != 1 {
// create panic when exitCode is not 1
panic("Workflow with invalid backend setup should not start")
}
}
13 changes: 6 additions & 7 deletions tests/perf/workflows/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

var tr *runner.TestRunner
var appNamePrefix = "perf-workflowsapp"
var backend = os.Getenv("DAPR_PERF_WORKFLOW_BACKEND_NAME")

type K6RunConfig struct {
TARGET_URL string
Expand All @@ -46,8 +47,6 @@ type K6RunConfig struct {
}

func TestMain(m *testing.M) {
backend := os.Getenv("DAPR_PERF_WORKFLOW_BACKEND_NAME")

utils.SetupLogs("workflow_test")
testApps := []kube.AppDescription{
{
Expand Down Expand Up @@ -204,15 +203,15 @@ func TestWorkflowWithConstantVUs(t *testing.T) {
inputs := []string{"100"}
scenarios := []string{"t_30_300", "t_30_300", "t_30_300"}
rateChecks := [][]string{{"rate==1", "rate==1", "rate==1"}}
testWorkflow(t, workflowName, appNamePrefix, inputs, scenarios, rateChecks, false, false)
testWorkflow(t, workflowName, appNamePrefix+backend, inputs, scenarios, rateChecks, false, false)
}

func TestWorkflowWithConstantIterations(t *testing.T) {
workflowName := "sum_series_wf"
inputs := []string{"100"}
scenarios := []string{"t_30_300", "t_60_300", "t_90_300"}
rateChecks := [][]string{{"rate==1", "rate==1", "rate==1"}}
testWorkflow(t, workflowName, appNamePrefix, inputs, scenarios, rateChecks, true, false)
testWorkflow(t, workflowName, appNamePrefix+backend, inputs, scenarios, rateChecks, true, false)
}

// Runs tests for `sum_series_wf` with Max VUs
Expand All @@ -221,7 +220,7 @@ func TestSeriesWorkflowWithMaxVUs(t *testing.T) {
inputs := []string{"100"}
scenarios := []string{"t_350_1400"}
rateChecks := [][]string{{"rate==1"}}
testWorkflow(t, workflowName, appNamePrefix, inputs, scenarios, rateChecks, true, false)
testWorkflow(t, workflowName, appNamePrefix+backend, inputs, scenarios, rateChecks, true, false)
}

// Runs tests for `sum_parallel_wf` with Max VUs
Expand All @@ -230,7 +229,7 @@ func TestParallelWorkflowWithMaxVUs(t *testing.T) {
inputs := []string{"100"}
scenarios := []string{"t_110_440"}
rateChecks := [][]string{{"rate==1"}}
testWorkflow(t, workflowName, appNamePrefix, inputs, scenarios, rateChecks, true, false)
testWorkflow(t, workflowName, appNamePrefix+backend, inputs, scenarios, rateChecks, true, false)
}

// Runs tests for `state_wf` with different Payload
Expand All @@ -239,5 +238,5 @@ func TestWorkflowWithDifferentPayloads(t *testing.T) {
scenarios := []string{"t_30_300"}
inputs := []string{"10000", "50000", "100000"}
rateChecks := [][]string{{"rate==1"}, {"rate==1"}, {"rate==1"}}
testWorkflow(t, workflowName, appNamePrefix, inputs, scenarios, rateChecks, true, true)
testWorkflow(t, workflowName, appNamePrefix+backend, inputs, scenarios, rateChecks, true, true)
}
Loading