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

fix: skip creating multiple component for symlink test #1396

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 20 additions & 29 deletions tests/build/build_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build",
Describe("HACBS pipelines", Ordered, Label("pipeline"), func() {

var applicationName, symlinkPRunName, testNamespace string
symlinkComponents := make(map[string]ComponentScenarioSpec)
components := make(map[string]ComponentScenarioSpec)
var kubeadminClient *framework.ControllerHub
var pipelineRunsWithE2eFinalizer []string
Expand All @@ -208,15 +207,10 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build",

symlinkScenario := GetComponentScenarioDetailsFromGitUrl(pythonComponentGitHubURL)
Expect(symlinkScenario.PipelineBundleNames).ShouldNot(BeEmpty())
for _, pipelineBundleName := range symlinkScenario.PipelineBundleNames {
componentName := fmt.Sprintf("test-symlink-comp-%s", util.GenerateRandomString(4))

s := symlinkScenario.DeepCopy()
s.Revision = gitRepoContainsSymlinkBranchName
s.PipelineBundleNames = []string{pipelineBundleName}

symlinkComponents[componentName] = s
}
symlinkComponentName := fmt.Sprintf("test-symlink-comp-%s", util.GenerateRandomString(4))
// Use the other value defined in componentScenarios in build_templates_scenario.go except revision and pipelineBundle
symlinkScenario.Revision = gitRepoContainsSymlinkBranchName
symlinkScenario.PipelineBundleNames = []string{"docker-build"}

BeforeAll(func() {
if os.Getenv("APP_SUFFIX") != "" {
Expand Down Expand Up @@ -256,9 +250,9 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build",
CreateComponent(kubeadminClient.CommonController, kubeadminClient.HasController, applicationName, componentName, testNamespace, scenario)
}

for componentName, scenario := range symlinkComponents {
CreateComponent(kubeadminClient.CommonController, kubeadminClient.HasController, applicationName, componentName, testNamespace, scenario)
}
// Create the symlink component
CreateComponent(kubeadminClient.CommonController, kubeadminClient.HasController, applicationName, symlinkComponentName, testNamespace, symlinkScenario)

})

AfterAll(func() {
Expand Down Expand Up @@ -310,14 +304,12 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build",
}
})

for symlinkComponentName := range symlinkComponents {
It(fmt.Sprintf("triggers PipelineRun for symlink component with source URL %s with component name %s", pythonComponentGitHubURL, symlinkComponentName), Label(buildTemplatesTestLabel, sourceBuildTestLabel), func() {
timeout := time.Minute * 5
symlinkPRunName = WaitForPipelineRunStarts(kubeadminClient, applicationName, symlinkComponentName, testNamespace, timeout)
Expect(symlinkPRunName).ShouldNot(BeEmpty())
pipelineRunsWithE2eFinalizer = append(pipelineRunsWithE2eFinalizer, symlinkPRunName)
})
}
It(fmt.Sprintf("triggers PipelineRun for symlink component with source URL %s with component name %s", pythonComponentGitHubURL, symlinkComponentName), Label(buildTemplatesTestLabel, sourceBuildTestLabel), func() {
timeout := time.Minute * 5
symlinkPRunName = WaitForPipelineRunStarts(kubeadminClient, applicationName, symlinkComponentName, testNamespace, timeout)
Expect(symlinkPRunName).ShouldNot(BeEmpty())
pipelineRunsWithE2eFinalizer = append(pipelineRunsWithE2eFinalizer, symlinkPRunName)
})

for componentName, scenario := range components {
componentName := componentName
Expand Down Expand Up @@ -723,14 +715,13 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build",
})
}

for symlinkComponentName := range symlinkComponents {
It(fmt.Sprintf("pipelineRun should fail for symlink component with Git source URL %s with component name %s", pythonComponentGitHubURL, symlinkComponentName), Label(buildTemplatesTestLabel, sourceBuildTestLabel), func() {
component, err := kubeadminClient.HasController.GetComponent(symlinkComponentName, testNamespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(kubeadminClient.HasController.WaitForComponentPipelineToBeFinished(component, "",
kubeadminClient.TektonController, &has.RetryOptions{Retries: 0}, nil)).Should(MatchError(ContainSubstring("cloned repository contains symlink pointing outside of the cloned repository")))
})
}
It(fmt.Sprintf("pipelineRun should fail for symlink component with Git source URL %s with component name %s", pythonComponentGitHubURL, symlinkComponentName), Label(buildTemplatesTestLabel, sourceBuildTestLabel), func() {
component, err := kubeadminClient.HasController.GetComponent(symlinkComponentName, testNamespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(kubeadminClient.HasController.WaitForComponentPipelineToBeFinished(component, "",
kubeadminClient.TektonController, &has.RetryOptions{Retries: 0}, nil)).Should(MatchError(ContainSubstring("cloned repository contains symlink pointing outside of the cloned repository")))
})

})
})

Expand Down
11 changes: 6 additions & 5 deletions tests/build/build_templates_scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ func (s ComponentScenarioSpec) DeepCopy() ComponentScenarioSpec {

var componentScenarios = []ComponentScenarioSpec{
{
GitURL: "https://github.com/konflux-qe-bd/devfile-sample-python-basic",
Revision: "47fc22092005aabebce233a9b6eab994a8152bbd",
ContextDir: ".",
DockerFilePath: constants.DockerFilePath,
PipelineBundleNames: []string{"docker-build", "docker-build-oci-ta", "docker-build-multi-platform-oci-ta"},
GitURL: "https://github.com/konflux-qe-bd/devfile-sample-python-basic",
Revision: "47fc22092005aabebce233a9b6eab994a8152bbd",
ContextDir: ".",
DockerFilePath: constants.DockerFilePath,
// "docker-build-multi-platform-oci-ta" needs to be enabled, when the issue https://issues.redhat.com/browse/KFLUXBUGS-1646 is fixed
PipelineBundleNames: []string{"docker-build", "docker-build-oci-ta"},
EnableHermetic: false,
PrefetchInput: "",
},
Expand Down
Loading