Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
#	internal/app/api/v1/testsuites.go
#	test/artillery/executor-smoke/crd/crd.yaml
#	test/container-executor/executor-smoke/crd/curl.yaml
#	test/container-executor/executor-smoke/crd/cypress.yaml
#	test/container-executor/executor-smoke/crd/k6.yaml
#	test/container-executor/executor-smoke/crd/playwright.yaml
#	test/curl/executor-tests/crd/smoke.yaml
#	test/ginkgo/executor-tests/crd/smoke.yaml
#	test/gradle/executor-smoke/crd/crd.yaml
#	test/jmeter/executor-tests/crd/smoke.yaml
#	test/k6/executor-tests/crd/other.yaml
#	test/k6/executor-tests/crd/smoke.yaml
#	test/kubepug/executor-smoke/crd/crd.yaml
#	test/playwright/executor-tests/crd/crd.yaml
#	test/soapui/executor-smoke/crd/crd.yaml
  • Loading branch information
vsukhin committed Oct 25, 2023
2 parents c20acea + 7302616 commit 18f5867
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 39 deletions.
6 changes: 3 additions & 3 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,7 @@ components:
description: configuration parameters for storing test artifacts
preRunScript:
type: string
description: script to run before test execution
description: script to run before test execution (not supported for container executors)
example: "echo -n '$SECRET_ENV' > ./secret_file"
postRunScript:
type: string
Expand Down Expand Up @@ -4762,7 +4762,7 @@ components:
description: adjusting parameters for test content
preRunScript:
type: string
description: script to run before test execution
description: script to run before test execution (not supported for container executors)
example: "echo -n '$SECRET_ENV' > ./secret_file"
postRunScript:
type: string
Expand Down Expand Up @@ -6003,4 +6003,4 @@ components:
- execution
filePath:
type: string
example: folder/file.txt
example: folder/file.txt
17 changes: 17 additions & 0 deletions cmd/kubectl-testkube/commands/tests/renderer/test_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ func TestRenderer(client client.Client, ui *ui.UI, obj interface{}) error {
if len(test.ExecutionRequest.Args) > 0 {
ui.Warn(" Args: ", test.ExecutionRequest.Args...)
}
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)

if test.ExecutionRequest.ArgsMode != "" {
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)
}

if test.ExecutionRequest.ArgsMode != "" {
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)
}

if test.ExecutionRequest.ArgsMode != "" {
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)
}

if test.ExecutionRequest.ArgsMode != "" {
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)
}

if test.ExecutionRequest.ArgsMode != "" {
ui.Warn(" Args mode: ", test.ExecutionRequest.ArgsMode)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/muesli/termenv v0.14.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nats-io/jwt/v2 v2.3.0 // indirect
github.com/nats-io/nats-server/v2 v2.8.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ github.com/moogar0880/problems v0.1.1/go.mod h1:5Dxrk2sD7BfBAgnOzQ1yaTiuCYdGPUh4
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.11.0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
github.com/muesli/termenv v0.13.0 h1:wK20DRpJdDX8b7Ek2QfhvqhRQFZ237RGRO0RQ/Iqdy0=
github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc=
github.com/muesli/termenv v0.14.0 h1:8x9NFfOe8lmIWK4pgy3IfVEy47f+ppe3tUqdPZG2Uy0=
github.com/muesli/termenv v0.14.0/go.mod h1:kG/pF1E7fh949Xhe156crRUrHNyK221IuGO7Ez60Uc8=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI=
Expand Down
28 changes: 14 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
echo "Getting kubectl-testkube plugin"

if [ ! -z "${DEBUG}" ];
then set -x
fi
if [ ! -z "${DEBUG}" ];
then set -x
fi

_detect_arch() {
case $(uname -m) in
amd64|x86_64) echo "x86_64"
;;
arm64|aarch64) echo "arm64"
;;
i386) echo "i386"
;;
*) echo "Unsupported processor architecture";
return 1
_detect_arch() {
case $(uname -m) in
amd64|x86_64) echo "x86_64"
;;
arm64|aarch64) echo "arm64"
;;
i386) echo "i386"
;;
*) echo "Unsupported processor architecture";
return 1
;;
esac
esac
}

_detect_os(){
Expand Down
13 changes: 11 additions & 2 deletions internal/app/api/v1/testsuites.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"
"strconv"
"strings"
"time"

"github.com/gofiber/fiber/v2"
"go.mongodb.org/mongo-driver/mongo"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/kubeshop/testkube/pkg/repository/testresult"
"github.com/kubeshop/testkube/pkg/scheduler"
"github.com/kubeshop/testkube/pkg/types"
"github.com/kubeshop/testkube/pkg/utils"
"github.com/kubeshop/testkube/pkg/workerpool"
)

Expand Down Expand Up @@ -665,24 +667,31 @@ func (s TestkubeAPI) ExecuteTestSuitesHandler() fiber.Handler {

func (s TestkubeAPI) ListTestSuiteExecutionsHandler() fiber.Handler {
return func(c *fiber.Ctx) error {

now := time.Now()
var l = s.Log.With("handler", "ListTestSuiteExecutionsHandler", "id", utils.RandAlphanum(10))

errPrefix := "failed to list test suite execution"
filter := getExecutionsFilterFromRequest(c)

ctx := c.Context()
executionsTotals, err := s.TestExecutionResults.GetExecutionsTotals(ctx, filter)
if err != nil {
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not get total executions: %w", errPrefix, err))
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not get executions totals: %w", errPrefix, err))
}
l.Debugw("got executions totals", "totals", executionsTotals, "time", time.Since(now)
nameFilter := testresult.NewExecutionsFilter().WithName(c.Query("id", ""))
allExecutionsTotals, err := s.TestExecutionResults.GetExecutionsTotals(ctx, nameFilter)
if err != nil {
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not get all total executions: %w", errPrefix, err))
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not get all executions totals: %w", errPrefix, err))
}
l.Debugw("got all executions totals", "totals", executionsTotals, "time", time.Since(now))

executions, err := s.TestExecutionResults.GetExecutions(ctx, filter)
if err != nil {
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not get executions: %w", errPrefix, err))
}
l.Debugw("got executions", "time", time.Since(now))

return c.JSON(testkube.TestSuiteExecutionsResult{
Totals: &allExecutionsTotals,
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1/testkube/model_test_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ type Test struct {
Uploads []string `json:"uploads,omitempty"`
ExecutionRequest *ExecutionRequest `json:"executionRequest,omitempty"`
Status *TestStatus `json:"status,omitempty"`
// true means that test is offline and cannot be executed
ReadOnly bool `json:"readOnly,omitempty"`

Check failure on line 40 in pkg/api/v1/testkube/model_test_base.go

View workflow job for this annotation

GitHub Actions / api

ReadOnly redeclared

Check failure on line 40 in pkg/api/v1/testkube/model_test_base.go

View workflow job for this annotation

GitHub Actions / Unit Tests

ReadOnly redeclared

Check failure on line 40 in pkg/api/v1/testkube/model_test_base.go

View workflow job for this annotation

GitHub Actions / Unit Tests

ReadOnly redeclared

Check failure on line 40 in pkg/api/v1/testkube/model_test_base.go

View workflow job for this annotation

GitHub Actions / Integration Tests

ReadOnly redeclared

Check failure on line 40 in pkg/api/v1/testkube/model_test_base.go

View workflow job for this annotation

GitHub Actions / Integration Tests

ReadOnly redeclared
}
10 changes: 9 additions & 1 deletion pkg/executor/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ func Run(ctx context.Context, r runner.Runner, args []string) {
}
}

output.PrintEvent("running test", e.Id)
// get event only when it's test run in main container
if r.GetType().IsMain() {
output.PrintEvent("running test", e.Id)
}

result, err := r.Run(ctx, e)

if r.GetType().IsMain() && e.PostRunScript != "" && !e.ExecutePostRunScriptBeforeScraping {
Expand All @@ -89,6 +93,10 @@ func Run(ctx context.Context, r runner.Runner, args []string) {
os.Exit(1)
}

if r.GetType().IsMain() {
output.PrintEvent("test execution finished", e.Id)
}

output.PrintResult(result)
}

Expand Down
2 changes: 1 addition & 1 deletion test/artillery/executor-smoke/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 256Mi\n cpu: 128m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/container-executor/executor-smoke/crd/curl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ spec:
value: https://testkube.non.existing.url.example
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 32Mi\n cpu: 32m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/container-executor/executor-smoke/crd/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ spec:
dirs:
- ./
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 2Gi\n cpu: 2\n"
activeDeadlineSeconds: 600
activeDeadlineSeconds: 600
2 changes: 1 addition & 1 deletion test/container-executor/executor-smoke/crd/k6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ spec:
executionRequest:
args: ["run", "k6-smoke-test-without-envs.js"]
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 64Mi\n cpu: 128m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/container-executor/executor-smoke/crd/playwright.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
dirs:
- ./
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 2Gi\n cpu: 2\n"
activeDeadlineSeconds: 600
activeDeadlineSeconds: 600
2 changes: 1 addition & 1 deletion test/curl/executor-tests/crd/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 32Mi\n cpu: 32m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/ginkgo/executor-tests/crd/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 512Mi\n cpu: 512m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/gradle/executor-smoke/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 512Mi\n cpu: 512m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/jmeter/executor-tests/crd/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 512Mi\n cpu: 512m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/k6/executor-tests/crd/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ spec:
- K6_ENV_FROM_PARAM=K6_ENV_FROM_PARAM_value
- k6-smoke-test.js
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 128Mi\n cpu: 128m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/k6/executor-tests/crd/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 128Mi\n cpu: 128m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/kubepug/executor-smoke/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 64Mi\n cpu: 128m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180
2 changes: 1 addition & 1 deletion test/playwright/executor-tests/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
path: test/playwright/executor-tests/playwright-project
executionRequest:
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 2Gi\n cpu: 2\n"
activeDeadlineSeconds: 600
activeDeadlineSeconds: 600
4 changes: 2 additions & 2 deletions test/scripts/executor-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ common_run() { # name, test_crd_file, testsuite_name, testsuite_file, custom_exe
kubectl --namespace $namespace apply -f $test_crd_file

# TestsSuites
create_update_testsuite "$testsuite_name" "$testsuite_file"
create_update_testsuite "$testsuite_file"
fi

if [ "$run" = true ] && [ "$custom_testsuite" = '' ]; then
Expand Down Expand Up @@ -336,7 +336,7 @@ main() {
filename=$(basename $custom_testsuite)
testsuite_name="${filename%%.*}"

create_update_testsuite "$testsuite_name" "$custom_testsuite"
create_update_testsuite "$custom_testsuite"
run_follow_testsuite "$testsuite_name"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion test/soapui/executor-smoke/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ spec:
executionRequest:
negativeTest: true
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 256Mi\n cpu: 512m\n"
activeDeadlineSeconds: 180
activeDeadlineSeconds: 180

0 comments on commit 18f5867

Please sign in to comment.