Skip to content

Commit

Permalink
Merge branch 'develop' into vsukhin/feature/execution-tags
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>

# Conflicts:
#	docs/docs/cli/testkube_get_testworkflowexecution.md
#	docs/docs/cli/testkube_run_testworkflow.md
#	go.mod
#	go.sum
#	pkg/api/v1/testkube/model_test_workflow_independent_step_parallel.go
#	pkg/api/v1/testkube/model_test_workflow_step_parallel.go
  • Loading branch information
vsukhin committed Aug 12, 2024
2 parents 78740b1 + 7120500 commit 4c57261
Show file tree
Hide file tree
Showing 649 changed files with 1,553 additions and 50,189 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.25.15
uses: github/codeql-action/init@v3.26.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand Down Expand Up @@ -82,4 +82,4 @@ jobs:
test-${{ runner.os }}-go-
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.25.15
uses: github/codeql-action/analyze@v3.26.0
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-api-executors-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow.yml
args: release -f goreleaser_files/.goreleaser-docker-build-${{ matrix.service }}.yml
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow.yml --snapshot
args: release -f goreleaser_files/.goreleaser-docker-build-${{ matrix.service }}.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow.yml --snapshot
args: release -f goreleaser_files/.goreleaser-docker-build-${{ matrix.service }}.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
Expand Down
47 changes: 0 additions & 47 deletions .github/workflows/docusaurus.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow.yml --snapshot
args: release -f goreleaser_files/.goreleaser-docker-build-${{ matrix.service }}.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@16639b4b1a370bc8a577d4d659aa0357b46cc5b2 # v2.25.3
uses: github/codeql-action/upload-sarif@5c02493ebfd65b28fd3b082c65e5af2cd745d91f # v2.25.3
with:
sarif_file: results.sarif
16 changes: 16 additions & 0 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8486,6 +8486,14 @@ components:
required:
- from

TestWorkflowSystem:
type: object
properties:
pureByDefault:
$ref: "#/components/schemas/BoxedBoolean"
isolatedContainers:
$ref: "#/components/schemas/BoxedBoolean"

TestWorkflowSpec:
type: object
properties:
Expand All @@ -8495,6 +8503,8 @@ components:
$ref: "#/components/schemas/TestWorkflowTemplateRef"
config:
$ref: "#/components/schemas/TestWorkflowConfigSchema"
system:
$ref: "#/components/schemas/TestWorkflowSystem"
content:
$ref: "#/components/schemas/TestWorkflowContent"
services:
Expand Down Expand Up @@ -8531,6 +8541,8 @@ components:
properties:
config:
$ref: "#/components/schemas/TestWorkflowConfigSchema"
system:
$ref: "#/components/schemas/TestWorkflowSystem"
content:
$ref: "#/components/schemas/TestWorkflowContent"
services:
Expand Down Expand Up @@ -8607,6 +8619,8 @@ components:
condition:
type: string
description: expression to declare under which conditions the step should be run; defaults to "passed", except artifacts where it defaults to "always"
pure:
$ref: "#/components/schemas/BoxedBoolean"
paused:
type: boolean
description: should the step be paused initially
Expand Down Expand Up @@ -8667,6 +8681,8 @@ components:
condition:
type: string
description: expression to declare under which conditions the step should be run; defaults to "passed", except artifacts where it defaults to "always"
pure:
$ref: "#/components/schemas/BoxedBoolean"
paused:
type: boolean
description: should the step be paused initially
Expand Down
1 change: 1 addition & 0 deletions build/testworkflow-init/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# syntax=docker/dockerfile:1
ARG BUSYBOX_IMAGE
FROM ${BUSYBOX_IMAGE}
RUN cp -rf /bin /.tktw-bin
COPY testworkflow-init /init
USER 1001
ENTRYPOINT ["/init"]
5 changes: 5 additions & 0 deletions build/testworkflow-toolkit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# syntax=docker/dockerfile:1
ARG BUSYBOX_IMAGE
ARG ALPINE_IMAGE

FROM ${BUSYBOX_IMAGE} AS busybox
FROM ${ALPINE_IMAGE}
RUN apk --no-cache add ca-certificates libssl3 git openssh-client
COPY --from=busybox /bin /.tktw-bin
COPY testworkflow-toolkit /toolkit
COPY testworkflow-init /init
RUN adduser --disabled-password --home / --no-create-home --uid 1001 default
USER 1001
ENTRYPOINT ["/toolkit"]
4 changes: 1 addition & 3 deletions cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ import (
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowexecutor"
)

var verbose = flag.Bool("v", false, "enable verbosity level")

func init() {
flag.Parse()
}
Expand Down Expand Up @@ -208,7 +206,7 @@ func main() {
cfg.TestkubeProURL,
cfg.TestkubeProCertFile,
cfg.TestkubeProKeyFile,
cfg.TestkubeProCAFile,
cfg.TestkubeProCAFile, //nolint
log.DefaultLogger,
)
exitOnError("error creating gRPC connection", err)
Expand Down
11 changes: 11 additions & 0 deletions cmd/kubectl-testkube/commands/common/validator/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/render"
"github.com/kubeshop/testkube/pkg/ui"
)

var ErrOldClientVersion = fmt.Errorf("client version is older than api version, please upgrade")

// PersistentPreRunVersionCheck will check versions based on commands client
func PersistentPreRunVersionCheck(cmd *cobra.Command, clientVersion string) {
outputFlag := cmd.Flag("output")
outputType := render.OutputPretty
if outputFlag != nil {
outputType = render.OutputType(outputFlag.Value.String())
}

if outputType != render.OutputPretty {
return
}

// version validation
// if client version is less than server version show warning
client, _, err := common.GetClient(cmd)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tcl/testworkflow-toolkit/commands/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func NewServicesCmd() *cobra.Command {
v, err := expressions.EvalTemplate(svcSpec.Timeout, machines...)
ui.ExitOnError(fmt.Sprintf("%s: %d: error: timeout expression", commontcl.ServiceLabel(name), index), err)
d, err := time.ParseDuration(strings.ReplaceAll(v, " ", ""))
ui.ExitOnError(fmt.Sprintf("%s: %d: error: invalid timeout: %s:", commontcl.ServiceLabel(name), index, v), err)
ui.ExitOnError(fmt.Sprintf("%s: %d: error: invalid timeout: %s", commontcl.ServiceLabel(name), index, v), err)
svcInstances[index].Timeout = &d
}
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/tcl/testworkflow-toolkit/spawn/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ func ProcessFetch(transferSrv transfer.Server, fetch []testworkflowsv1.StepParal
ContainerConfig: testworkflowsv1.ContainerConfig{
Image: env.Config().Images.Toolkit,
ImagePullPolicy: corev1.PullIfNotPresent,
Command: common.Ptr([]string{"/toolkit", "transfer"}),
Command: common.Ptr([]string{constants.DefaultToolkitPath, "transfer"}),
Env: []corev1.EnvVar{
{Name: "TK_NS", Value: env.Namespace()},
{Name: "TK_REF", Value: env.Ref()},
stage.BypassToolkitCheck,
stage.BypassPure,
},
Args: &result,
},
Expand Down
16 changes: 15 additions & 1 deletion cmd/testworkflow-init/commands/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,26 @@ func Setup(config lite.ActionSetup) error {
stdoutUnsafe.Print(" skipped\n")
}

// Copy the toolkit
stdoutUnsafe.Print("Configuring toolkit...")
if config.CopyToolkit {
err := exec.Command("cp", "/toolkit", data.ToolkitPath).Run()
if err != nil {
stdoutUnsafe.Error(" error\n")
stdoutUnsafe.Errorf(" failed to copy the /toolkit utilities: %s\n", err.Error())
return err
}
stdoutUnsafe.Print(" done\n")
} else {
stdoutUnsafe.Print(" skipped\n")
}

// Copy the shell and useful libraries
stdoutUnsafe.Print("Configuring shell...")
if config.CopyBinaries {
// Use `cp` on the whole directory, as it has plenty of files, which lead to the same FS block.
// Copying individual files will lead to high FS usage
err := exec.Command("cp", "-rf", "/bin", data.InternalBinPath).Run()
err := exec.Command("cp", "-rf", "/.tktw-bin", data.InternalBinPath).Run()
if err != nil {
stdoutUnsafe.Error(" error\n")
stdoutUnsafe.Errorf(" failed to copy the binaries: %s\n", err.Error())
Expand Down
1 change: 1 addition & 0 deletions cmd/testworkflow-init/data/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
var (
InternalBinPath = filepath.Join(InternalPath, "bin")
InitPath = filepath.Join(InternalPath, "init")
ToolkitPath = filepath.Join(InternalPath, "toolkit")
StatePath = filepath.Join(InternalPath, "state")
)

Expand Down
1 change: 1 addition & 0 deletions cmd/testworkflow-init/orchestration/executions.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func (e *execution) Run() (*executionResult, error) {
e.group.pauseMu.Unlock()
e.cmdMu.Unlock()
_, exitCode = getProcessStatus(err)
e.cmd.Stderr.Write(append([]byte(err.Error()), '\n'))
}

// Clean up
Expand Down
2 changes: 1 addition & 1 deletion cmd/testworkflow-init/orchestration/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *setup) SetWorkingDir(workingDir string) {
wd = workingDir
_ = os.MkdirAll(wd, 0755)
} else {
err = os.MkdirAll(wd, 0755)
_ = os.MkdirAll(wd, 0755)
}
err = os.Chdir(wd)

Expand Down
3 changes: 3 additions & 0 deletions cmd/testworkflow-toolkit/artifacts/cloud_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type cloudUploader struct {
parallelism int
error atomic.Bool
reqEnhancers []CloudUploaderRequestEnhancer
waitMu sync.Mutex
}

func (d *cloudUploader) Start() (err error) {
Expand Down Expand Up @@ -140,6 +141,8 @@ func (d *cloudUploader) Add(path string, file io.Reader, size int64) error {
}

func (d *cloudUploader) End() error {
d.waitMu.Lock()
defer d.waitMu.Unlock()
d.wg.Wait()
if d.error.Load() {
return fmt.Errorf("upload failed")
Expand Down
20 changes: 0 additions & 20 deletions docs/.gitignore

This file was deleted.

Loading

0 comments on commit 4c57261

Please sign in to comment.