-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(testworkflows): support `services` in the TestWorkflow objects * feat(testworkflows): support `use` in `services` * fix(testworkflows): orchestration fixes * feat(testworkflows): TKC-1764 - add support for accompanying services * chore: update integration tests to use provided URLs * chore: update integration tests to use provided Minio URLs * chore: fix NATS URIs in tests * chore: hardcode again Minio buckets for tests * fix: add missing environment variables for integration tests * fix(testworkflows): cloning the repository * fix(testworkflows): merging securityContext * fix(testworkflows): sort out proper group/fsGroup/user for the services * feat(testworkflows): add example integration tests for Testkube * fix: adjust make integration-tests to fill the access/secret keys * chore: update testkube-operator * feat: expose PWD environment variable for the processing
- Loading branch information
Showing
52 changed files
with
1,635 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright 2024 Testkube. | ||
// | ||
// Licensed as a Testkube Pro file under the Testkube Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt | ||
|
||
package commands | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"slices" | ||
|
||
"github.com/spf13/cobra" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/kubeshop/testkube/cmd/tcl/testworkflow-init/data" | ||
"github.com/kubeshop/testkube/cmd/tcl/testworkflow-toolkit/artifacts" | ||
"github.com/kubeshop/testkube/cmd/tcl/testworkflow-toolkit/common" | ||
"github.com/kubeshop/testkube/cmd/tcl/testworkflow-toolkit/env" | ||
"github.com/kubeshop/testkube/cmd/tcl/testworkflow-toolkit/spawn" | ||
"github.com/kubeshop/testkube/pkg/tcl/testworkflowstcl/testworkflowcontroller" | ||
"github.com/kubeshop/testkube/pkg/tcl/testworkflowstcl/testworkflowprocessor/constants" | ||
"github.com/kubeshop/testkube/pkg/ui" | ||
) | ||
|
||
func NewKillCmd() *cobra.Command { | ||
var ( | ||
logs []string | ||
) | ||
cmd := &cobra.Command{ | ||
Use: "kill <ref>", | ||
Short: "Kill accompanying service(s)", | ||
Args: cobra.ExactArgs(1), | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
groupRef := args[0] | ||
clientSet := env.Kubernetes() | ||
|
||
// Fast-track | ||
if len(logs) == 0 { | ||
os.Exit(0) | ||
} | ||
|
||
// Fetch the services when needed | ||
if len(logs) > 0 { | ||
jobs, err := clientSet.BatchV1().Jobs(env.Namespace()).List(context.Background(), metav1.ListOptions{ | ||
LabelSelector: fmt.Sprintf("%s=%s", constants.GroupIdLabelName, groupRef), | ||
}) | ||
ui.ExitOnError("listing service resources", err) | ||
|
||
services := make(map[string]int64) | ||
ids := make([]string, 0) | ||
for _, job := range jobs.Items { | ||
service, _ := spawn.GetServiceByResourceId(job.Name) | ||
if slices.Contains(logs, service) { | ||
services[service]++ | ||
ids = append(ids, job.Name) | ||
} | ||
} | ||
|
||
// Inform about detected services | ||
for name, count := range services { | ||
fmt.Printf("%s: fetching logs of %d instances\n", common.ServiceLabel(name), count) | ||
} | ||
|
||
// Fetch logs for them | ||
storage := artifacts.InternalStorage() | ||
for _, id := range ids { | ||
service, index := spawn.GetServiceByResourceId(id) | ||
count := index + 1 | ||
if services[service] > count { | ||
count = services[service] | ||
} | ||
log := spawn.CreateLogger(service, "", index, count) | ||
|
||
logsFilePath, err := spawn.SaveLogs(context.Background(), clientSet, storage, env.Namespace(), id, service+"/", index) | ||
if err == nil { | ||
data.PrintOutput(env.Ref(), "service", ServiceInfo{Group: groupRef, Name: service, Index: index, Logs: storage.FullPath(logsFilePath)}) | ||
log("saved logs") | ||
} else { | ||
log("warning", "problem saving the logs", err.Error()) | ||
} | ||
} | ||
} | ||
|
||
err := testworkflowcontroller.CleanupGroup(context.Background(), clientSet, env.Namespace(), groupRef) | ||
ui.ExitOnError("cleaning up resources", err) | ||
}, | ||
} | ||
|
||
cmd.Flags().StringArrayVarP(&logs, "logs", "l", nil, "fetch the logs for specific services") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.