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

feat(KONFLUX-4319): Capture Application & Component JSONs after load test #1459

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 0 additions & 8 deletions tests/load-tests/ci-scripts/collect-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ application_stub=$ARTIFACT_DIR/collected-data/collected-applications.appstudio.r
component_stub=$ARTIFACT_DIR/collected-data/collected-components.appstudio.redhat.com
node_stub=$ARTIFACT_DIR/collected-data/collected-nodes

## Application info
echo "Collecting Application timestamps..."
collect_application "-A" "$application_stub"

## Component info
echo "Collecting Component timestamps..."
collect_component "-A" "$component_stub"

## Nodes info
#echo "Collecting node specs"
#collect_nodes "$node_stub"
Expand Down
7 changes: 0 additions & 7 deletions tests/load-tests/ci-scripts/stage/collect-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ else
fi
tenant="${username}-tenant"

# Application info
echo "Collecting Application timestamps..."
collect_application "-n ${tenant}" "$application_stub-$tenant" || echo "ERROR: Failed collecting applications"

# Component info
echo "Collecting Component timestamps..."
collect_component "-n ${tenant}" "$component_stub-$tenant" || echo "ERROR: Failed collecting components"
done
fi

Expand Down
59 changes: 53 additions & 6 deletions tests/load-tests/pkg/journey/handle_collections.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package journey

import "fmt"
rh-rahulshetty marked this conversation as resolved.
Show resolved Hide resolved
import "os"
import "path/filepath"
import "encoding/json"
import (
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"

import logging "github.com/konflux-ci/e2e-tests/tests/load-tests/pkg/logging"
logging "github.com/konflux-ci/e2e-tests/tests/load-tests/pkg/logging"

import framework "github.com/konflux-ci/e2e-tests/pkg/framework"
framework "github.com/konflux-ci/e2e-tests/pkg/framework"
)

func getDirName(baseDir, namespace, iteration string) string {
return filepath.Join(baseDir, "collected-data", namespace, iteration) + "/"
Expand Down Expand Up @@ -131,6 +134,45 @@ func collectPipelineRunJSONs(f *framework.Framework, dirPath, namespace, applica
return nil
}

func collectApplicationComponentJSONs(f *framework.Framework, dirPath, namespace, application, component string) error {
// Only save Application JSON if it has not already been collected (as HandlePerComponentCollection method is called for each component)
if _, err := os.Stat(filepath.Join(dirPath, "collected-application-" + application + ".json")); errors.Is(err, os.ErrNotExist) {
rh-rahulshetty marked this conversation as resolved.
Show resolved Hide resolved
// Get Application JSON
app, err := f.AsKubeDeveloper.HasController.GetApplication(application, namespace)
if err != nil {
return fmt.Errorf("Failed to get Application %s: %v", application, err)
}

appJSON, err := json.Marshal(app)
if err != nil {
return fmt.Errorf("Failed to dump Application JSON: %v", err)
}

err = writeToFile(dirPath, "collected-application-" + application + ".json", appJSON)
if err != nil {
return fmt.Errorf("Failed to write Application: %v", err)
}
}

// Collect Component JSON
comp, err := f.AsKubeDeveloper.HasController.GetComponent(component, namespace)
if err != nil {
return fmt.Errorf("Failed to get Component %s: %v", component, err)
}

compJSON, err := json.Marshal(comp)
if err != nil {
return fmt.Errorf("Failed to dump Component JSON: %v", err)
}

err = writeToFile(dirPath, "collected-component-" + component + ".json", compJSON)
if err != nil {
return fmt.Errorf("Failed to write Component: %v", err)
}

return nil
}

func HandlePerComponentCollection(ctx *PerComponentContext) error {
if ctx.ComponentName == "" {
logging.Logger.Debug("Component name not populated, so skipping per-component collections in %s", ctx.ParentContext.ParentContext.Namespace)
Expand All @@ -156,5 +198,10 @@ func HandlePerComponentCollection(ctx *PerComponentContext) error {
return logging.Logger.Fail(102, "Failed to collect pipeline run JSONs: %v", err)
}

err = collectApplicationComponentJSONs(ctx.Framework, dirPath, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.ApplicationName, ctx.ComponentName)
if err != nil {
return logging.Logger.Fail(102, "Failed to collect Application and Component JSONs: %v", err)
}

return nil
}
Loading