Skip to content

Commit

Permalink
Add/run groups to cli (#3753)
Browse files Browse the repository at this point in the history
* feat: adding run multiple tests feature

* wip

* feat: cli run group reporter (#3751)

add run group reporter to CLI

* fix cli panic

* comment code to prevent cli from breaking

* small refactor on how to read resource type from file

* initialize logger in cmdutil

* small refactor on initialization

* wip

* wip

* Adding base logic and formatter

* fixing types

* adding lower case for name

* CLI run groups v1

* Adding metadata

* Fixing version

* Adding group flag and dir support

* Fixing variable set http client

* Fixing tests

* updating old scenarios

* fixing test

---------

Co-authored-by: Daniel Dias <danielbpdias@gmail.com>
Co-authored-by: Oscar Reyes <oscar-rreyes1@hotmail.com>
  • Loading branch information
3 people committed Apr 4, 2024
1 parent 1b8f5a8 commit 4f6165b
Show file tree
Hide file tree
Showing 37 changed files with 1,713 additions and 279 deletions.
391 changes: 391 additions & 0 deletions cli/cloud/LICENSE

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions cli/cloud/cmd/run_cmd.go
@@ -0,0 +1,63 @@
package cmd

import (
"context"
"fmt"

"github.com/kubeshop/tracetest/cli/cloud/runner"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/formatters"
"github.com/kubeshop/tracetest/cli/pkg/resourcemanager"
"github.com/kubeshop/tracetest/cli/preprocessor"

cliRunner "github.com/kubeshop/tracetest/cli/runner"
)

func RunMultipleFiles(ctx context.Context, runParams *cmdutil.RunParameters, cliConfig *config.Config, runnerRegistry cliRunner.Registry, format string) (int, error) {
if cliConfig.Jwt == "" {
return cliRunner.ExitCodeGeneralError, fmt.Errorf("you should be authenticated to run multiple files, please run 'tracetest configure'")
}

variableSetPreprocessor := preprocessor.VariableSet(cmdutil.GetLogger())

formatter := formatters.MultipleRun[cliRunner.RunResult](func() string { return cliConfig.UI() }, true)

orchestrator := runner.MultiFileOrchestrator(
cmdutil.GetLogger(),
config.GetAPIClient(*cliConfig),
GetVariableSetClient(variableSetPreprocessor),
runnerRegistry,
formatter,
)

return orchestrator.Run(ctx, runner.RunOptions{
DefinitionFiles: runParams.DefinitionFiles,
VarsID: runParams.VarsID,
SkipResultWait: runParams.SkipResultWait,
JUnitOuptutFile: runParams.JUnitOuptutFile,
RequiredGates: runParams.RequiredGates,
RunGroupID: runParams.RunGroupID,
}, format)
}

func GetVariableSetClient(preprocessor preprocessor.Preprocessor) resourcemanager.Client {
httpClient := &resourcemanager.HTTPClient{}

variableSetClient := resourcemanager.NewClient(
httpClient, cmdutil.GetLogger(),
"variableset", "variablesets",
resourcemanager.WithTableConfig(resourcemanager.TableConfig{
Cells: []resourcemanager.TableCellConfig{
{Header: "ID", Path: "spec.id"},
{Header: "NAME", Path: "spec.name"},
{Header: "DESCRIPTION", Path: "spec.description"},
},
}),
resourcemanager.WithResourceType("VariableSet"),
resourcemanager.WithApplyPreProcessor(preprocessor.Preprocess),
resourcemanager.WithDeprecatedAlias("Environment"),
)

return variableSetClient
}

0 comments on commit 4f6165b

Please sign in to comment.