Skip to content

Commit

Permalink
style: If function do not have to be public, make it private
Browse files Browse the repository at this point in the history
  • Loading branch information
jhutar committed Jun 11, 2024
1 parent 7ee1f4f commit 751c632
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 28 deletions.
19 changes: 15 additions & 4 deletions tests/load-tests/pkg/journey/handle_applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import logging "github.com/konflux-ci/e2e-tests/tests/load-tests/pkg/logging"
import framework "github.com/konflux-ci/e2e-tests/pkg/framework"
import utils "github.com/konflux-ci/e2e-tests/pkg/utils"

func CreateApplication(f *framework.Framework, namespace string, timeout time.Duration, name string) error {
func createApplication(f *framework.Framework, namespace string, timeout time.Duration, name string) error {
_, err := f.AsKubeDeveloper.HasController.CreateApplicationWithTimeout(name, namespace, timeout)
if err != nil {
return fmt.Errorf("Unable to create the Application %s: %v", name, err)
}
return nil
}

func ValidateApplication(f *framework.Framework, name, namespace string) error {
func validateApplication(f *framework.Framework, name, namespace string) error {
interval := time.Second * 20
timeout := time.Minute * 15

Expand All @@ -39,12 +39,23 @@ func HandleApplication(ctx *PerApplicationContext) error {

logging.Logger.Debug("Creating application %s in namespace %s", ctx.ApplicationName, ctx.ParentContext.Namespace)

_, err = logging.Measure(CreateApplication, ctx.Framework, ctx.ParentContext.Namespace, time.Minute*60, ctx.ApplicationName)
_, err = logging.Measure(
createApplication,
ctx.Framework,
ctx.ParentContext.Namespace,
time.Minute*60,
ctx.ApplicationName,
)
if err != nil {
return logging.Logger.Fail(30, "Application failed creation: %v", err)
}

_, err = logging.Measure(ValidateApplication, ctx.Framework, ctx.ApplicationName, ctx.ParentContext.Namespace)
_, err = logging.Measure(
validateApplication,
ctx.Framework,
ctx.ApplicationName,
ctx.ParentContext.Namespace,
)
if err != nil {
return logging.Logger.Fail(31, "Application failed validation: %v", err)
}
Expand Down
10 changes: 5 additions & 5 deletions tests/load-tests/pkg/journey/handle_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func getPaCPull(annotations map[string]string) (string, error) {
}
}

func CreateComponent(f *framework.Framework, namespace, name, repoUrl, repoRevision, containerContext, containerFile, buildPipelineSelector, appName string, skipInitialChecks, requestConfigurePac bool) error {
func createComponent(f *framework.Framework, namespace, name, repoUrl, repoRevision, containerContext, containerFile, buildPipelineSelector, appName string, skipInitialChecks, requestConfigurePac bool) error {
// Prepare annotations to add to component
var annotationsMap map[string]string

Check failure on line 81 in tests/load-tests/pkg/journey/handle_component.go

View workflow job for this annotation

GitHub Actions / lint

S1021: should merge variable declaration with assignment on next line (gosimple)
annotationsMap = constants.DefaultDockerBuildPipelineBundle
Expand Down Expand Up @@ -196,7 +196,7 @@ func listAndDeletePipelineRunsWithTimeout(f *framework.Framework, namespace, app
}

// This handles post-component creation tasks for multi-arch PaC workflow
func UtilityMultiArchComponentCleanup(f *framework.Framework, namespace, appName, compName, repoUrl, repoRev string, mergeReqNum int, placeholders *map[string]string) error {
func utilityMultiArchComponentCleanup(f *framework.Framework, namespace, appName, compName, repoUrl, repoRev string, mergeReqNum int, placeholders *map[string]string) error {
var repoName string
var err error

Expand Down Expand Up @@ -226,7 +226,7 @@ func UtilityMultiArchComponentCleanup(f *framework.Framework, namespace, appName
logging.Logger.Debug("Multi-arch workflow: Cleaned up (second cleanup) for %s/%s/%s", namespace, appName, compName)

// Template our multi-arch PaC files
shaMap, err := TemplateFiles(f, repoUrl, repoRev, placeholders)
shaMap, err := templateFiles(f, repoUrl, repoRev, placeholders)
if err != nil {
return fmt.Errorf("Error templating PaC files: %v", err)
}
Expand All @@ -253,7 +253,7 @@ func HandleComponent(ctx *PerComponentContext) error {

// Create component
_, err = logging.Measure(
CreateComponent,
createComponent,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ComponentName,
Expand Down Expand Up @@ -303,7 +303,7 @@ func HandleComponent(ctx *PerComponentContext) error {

// Skip what we do not care about
_, err = logging.Measure(
UtilityMultiArchComponentCleanup,
utilityMultiArchComponentCleanup,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.ApplicationName,
Expand Down
23 changes: 19 additions & 4 deletions tests/load-tests/pkg/journey/handle_integration_test_scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import utils "github.com/konflux-ci/e2e-tests/pkg/utils"
import integrationApi "github.com/konflux-ci/integration-service/api/v1beta1"
import types "k8s.io/apimachinery/pkg/types"

func CreateIntegrationTestScenario(f *framework.Framework, namespace, name, appName, scenarioGitURL, scenarioRevision, scenarioPathInRepo string) error {
func createIntegrationTestScenario(f *framework.Framework, namespace, name, appName, scenarioGitURL, scenarioRevision, scenarioPathInRepo string) error {
_, err := f.AsKubeDeveloper.IntegrationController.CreateIntegrationTestScenario(name, appName, namespace, scenarioGitURL, scenarioRevision, scenarioPathInRepo)
if err != nil {
return fmt.Errorf("Unable to create the Integration Test Scenario %s: %v", name, err)
}
return nil
}

func ValidateIntegrationTestScenario(f *framework.Framework, namespace, name, appName string) error {
func validateIntegrationTestScenario(f *framework.Framework, namespace, name, appName string) error {
interval := time.Second * 20
timeout := time.Minute * 15
var its integrationApi.IntegrationTestScenario
Expand Down Expand Up @@ -64,12 +64,27 @@ func HandleIntegrationTestScenario(ctx *PerApplicationContext) error {
name := fmt.Sprintf("%s-its-%s", ctx.ParentContext.Username, util.GenerateRandomString(5))
logging.Logger.Debug("Creating integration test scenario %s for application %s in namespace %s", name, ctx.ApplicationName, ctx.ParentContext.Namespace)

_, err = logging.Measure(CreateIntegrationTestScenario, ctx.Framework, ctx.ParentContext.Namespace, name, ctx.ApplicationName, ctx.ParentContext.Opts.TestScenarioGitURL, ctx.ParentContext.Opts.TestScenarioRevision, ctx.ParentContext.Opts.TestScenarioPathInRepo)
_, err = logging.Measure(
createIntegrationTestScenario,
ctx.Framework,
ctx.ParentContext.Namespace,
name,
ctx.ApplicationName,
ctx.ParentContext.Opts.TestScenarioGitURL,
ctx.ParentContext.Opts.TestScenarioRevision,
ctx.ParentContext.Opts.TestScenarioPathInRepo,
)
if err != nil {
return logging.Logger.Fail(40, "Integration test scenario failed creation: %v", err)
}

_, err = logging.Measure(ValidateIntegrationTestScenario, ctx.Framework, ctx.ParentContext.Namespace, name, ctx.ApplicationName)
_, err = logging.Measure(
validateIntegrationTestScenario,
ctx.Framework,
ctx.ParentContext.Namespace,
name,
ctx.ApplicationName,
)
if err != nil {
return logging.Logger.Fail(41, "Integration test scenario failed validation: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import logging "github.com/konflux-ci/e2e-tests/tests/load-tests/pkg/logging"
import framework "github.com/konflux-ci/e2e-tests/pkg/framework"
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

func CollectPersistentVolumeClaims(f *framework.Framework, namespace string) error {
func collectPersistentVolumeClaims(f *framework.Framework, namespace string) error {
pvcs, err := f.AsKubeAdmin.TektonController.KubeInterface().CoreV1().PersistentVolumeClaims(namespace).List(context.Background(), metav1.ListOptions{})
if err != nil {
return fmt.Errorf("Error getting PVC: %v\n", err)
Expand Down Expand Up @@ -38,7 +38,10 @@ func HandlePersistentVolumeClaim(ctx *MainContext) error {

logging.Logger.Debug("Collecting persistent volume claim wait times in namespace %s", ctx.Namespace)

err = CollectPersistentVolumeClaims(ctx.Framework, ctx.Namespace)
err = collectPersistentVolumeClaims(
ctx.Framework,
ctx.Namespace,
)
if err != nil {
return logging.Logger.Fail(75, "Collecting persistent volume claim failed: %v", err)
}
Expand Down
30 changes: 24 additions & 6 deletions tests/load-tests/pkg/journey/handle_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import framework "github.com/konflux-ci/e2e-tests/pkg/framework"
import utils "github.com/konflux-ci/e2e-tests/pkg/utils"
import pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"

func ValidatePipelineRunCreation(f *framework.Framework, namespace, appName, compName string) error {
func validatePipelineRunCreation(f *framework.Framework, namespace, appName, compName string) error {
interval := time.Second * 20
timeout := time.Minute * 30

Expand All @@ -27,7 +27,7 @@ func ValidatePipelineRunCreation(f *framework.Framework, namespace, appName, com
return err
}

func ValidatePipelineRunCondition(f *framework.Framework, namespace, appName, compName string) error {
func validatePipelineRunCondition(f *framework.Framework, namespace, appName, compName string) error {
interval := time.Second * 20
timeout := time.Minute * 60
var pr *pipeline.PipelineRun
Expand Down Expand Up @@ -63,7 +63,7 @@ func ValidatePipelineRunCondition(f *framework.Framework, namespace, appName, co
return err
}

func ValidatePipelineRunSignature(f *framework.Framework, namespace, appName, compName string) error {
func validatePipelineRunSignature(f *framework.Framework, namespace, appName, compName string) error {
interval := time.Second * 20
timeout := time.Minute * 60
var pr *pipeline.PipelineRun
Expand Down Expand Up @@ -108,17 +108,35 @@ func HandlePipelineRun(ctx *PerComponentContext) error {

logging.Logger.Debug("Creating build pipeline run for component %s in namespace %s", ctx.ComponentName, ctx.ParentContext.ParentContext.Namespace)

_, err = logging.Measure(ValidatePipelineRunCreation, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.ApplicationName, ctx.ComponentName)
_, err = logging.Measure(
validatePipelineRunCreation,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.ApplicationName,
ctx.ComponentName,
)
if err != nil {
return logging.Logger.Fail(70, "Build Pipeline Run failed creation: %v", err)
}

_, err = logging.Measure(ValidatePipelineRunCondition, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.ApplicationName, ctx.ComponentName)
_, err = logging.Measure(
validatePipelineRunCondition,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.ApplicationName,
ctx.ComponentName,
)
if err != nil {
return logging.Logger.Fail(71, "Build Pipeline Run failed run: %v", err)
}

_, err = logging.Measure(ValidatePipelineRunSignature, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.ApplicationName, ctx.ComponentName)
_, err = logging.Measure(
validatePipelineRunSignature,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.ApplicationName,
ctx.ComponentName,
)
if err != nil {
return logging.Logger.Fail(72, "Build Pipeline Run failed signing: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/load-tests/pkg/journey/handle_repo_templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func ForkRepo(f *framework.Framework, repoUrl, repoRevision, username string) (s
return forkRepo.GetHTMLURL(), nil
}

func TemplateFiles(f *framework.Framework, repoUrl, repoRevision string, placeholders *map[string]string) (*map[string]string, error) {
func templateFiles(f *framework.Framework, repoUrl, repoRevision string, placeholders *map[string]string) (*map[string]string, error) {
var sha string

// Get repo name from repo url
Expand Down
29 changes: 23 additions & 6 deletions tests/load-tests/pkg/journey/handle_test_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import framework "github.com/konflux-ci/e2e-tests/pkg/framework"
import utils "github.com/konflux-ci/e2e-tests/pkg/utils"
import pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"

func ValidateSnapshotCreation(f *framework.Framework, namespace, compName string) (string, error) {
func validateSnapshotCreation(f *framework.Framework, namespace, compName string) (string, error) {
interval := time.Second * 20
timeout := time.Minute * 30
var snap *appstudioApi.Snapshot
Expand All @@ -29,7 +29,7 @@ func ValidateSnapshotCreation(f *framework.Framework, namespace, compName string
return snap.Name, err
}

func ValidateTestPipelineRunCreation(f *framework.Framework, namespace, itsName, snapName string) error {
func validateTestPipelineRunCreation(f *framework.Framework, namespace, itsName, snapName string) error {
interval := time.Second * 20
timeout := time.Minute * 30

Expand All @@ -46,7 +46,7 @@ func ValidateTestPipelineRunCreation(f *framework.Framework, namespace, itsName,
return err
}

func ValidateTestPipelineRunCondition(f *framework.Framework, namespace, itsName, snapName string) error {
func validateTestPipelineRunCondition(f *framework.Framework, namespace, itsName, snapName string) error {
interval := time.Second * 20
timeout := time.Minute * 60
var pr *pipeline.PipelineRun
Expand Down Expand Up @@ -92,7 +92,12 @@ func HandleTest(ctx *PerComponentContext) error {

logging.Logger.Debug("Creating test pipeline run for component %s in namespace %s", ctx.ComponentName, ctx.ParentContext.ParentContext.Namespace)

result1, err1 := logging.Measure(ValidateSnapshotCreation, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ComponentName)
result1, err1 := logging.Measure(
validateSnapshotCreation,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ComponentName,
)
if err1 != nil {
return logging.Logger.Fail(80, "Snapshot failed creation: %v", err1)
}
Expand All @@ -101,12 +106,24 @@ func HandleTest(ctx *PerComponentContext) error {
return logging.Logger.Fail(81, "Snapshot name type assertion failed")
}

_, err = logging.Measure(ValidateTestPipelineRunCreation, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.IntegrationTestScenarioName, ctx.SnapshotName)
_, err = logging.Measure(
validateTestPipelineRunCreation,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.IntegrationTestScenarioName,
ctx.SnapshotName,
)
if err != nil {
return logging.Logger.Fail(82, "Test Pipeline Run failed creation: %v", err)
}

_, err = logging.Measure(ValidateTestPipelineRunCondition, ctx.Framework, ctx.ParentContext.ParentContext.Namespace, ctx.ParentContext.IntegrationTestScenarioName, ctx.SnapshotName)
_, err = logging.Measure(
validateTestPipelineRunCondition,
ctx.Framework,
ctx.ParentContext.ParentContext.Namespace,
ctx.ParentContext.IntegrationTestScenarioName,
ctx.SnapshotName,
)
if err != nil {
return logging.Logger.Fail(83, "Test Pipeline Run failed run: %v", err)
}
Expand Down

0 comments on commit 751c632

Please sign in to comment.