From 8449f4882b034723f1a71ccbdb7355a7f115f2d7 Mon Sep 17 00:00:00 2001 From: Tomas Nevrlka Date: Wed, 11 Dec 2024 11:11:28 +0100 Subject: [PATCH] chore: remove references to jvm-build-service - jvm-build-service is currently not being used by anyone - It is going to undergo major breaking changes and is going to be removed for now until the changes are done - Current tests are probably going to be useless due to the rewrite --- magefiles/utils.go | 2 +- pkg/clients/jvmbuildservice/OWNERS | 2 - .../jvmbuildservice/artifact_builds.go | 18 - pkg/clients/jvmbuildservice/caches.go | 37 -- pkg/clients/jvmbuildservice/controller.go | 15 - .../jvmbuildservice/dependency_builds.go | 18 - pkg/clients/jvmbuildservice/jbs_configs.go | 70 --- .../jvmbuildservice/rebuilt_artifacts.go | 13 - pkg/constants/constants.go | 3 - pkg/framework/framework.go | 37 +- tests/build/jvm-build.go | 403 ------------------ tests/konflux-demo/konflux-demo.go | 39 -- 12 files changed, 15 insertions(+), 642 deletions(-) delete mode 100644 pkg/clients/jvmbuildservice/OWNERS delete mode 100644 pkg/clients/jvmbuildservice/artifact_builds.go delete mode 100644 pkg/clients/jvmbuildservice/caches.go delete mode 100644 pkg/clients/jvmbuildservice/controller.go delete mode 100644 pkg/clients/jvmbuildservice/dependency_builds.go delete mode 100644 pkg/clients/jvmbuildservice/jbs_configs.go delete mode 100644 pkg/clients/jvmbuildservice/rebuilt_artifacts.go delete mode 100644 tests/build/jvm-build.go diff --git a/magefiles/utils.go b/magefiles/utils.go index c46cdeafe..67020ad82 100644 --- a/magefiles/utils.go +++ b/magefiles/utils.go @@ -27,7 +27,7 @@ import ( "github.com/magefile/mage/sh" ) -const quayPrefixesToDeleteRegexp = "rhtap[-_]demo|happy-path|multi-platform|ex-registry|gitlab|build-e2e|build-templates|byoc|user1|spi|release-|integration|jvm|stat-rep|nbe|stack|rs[-_]demos|push-pyxis" +const quayPrefixesToDeleteRegexp = "rhtap[-_]demo|happy-path|multi-platform|ex-registry|gitlab|build-e2e|build-templates|byoc|user1|spi|release-|integration|stat-rep|nbe|stack|rs[-_]demos|push-pyxis" func getRemoteAndBranchNameFromPRLink(url string) (remote, branchName string, err error) { ghRes := &GithubPRInfo{} diff --git a/pkg/clients/jvmbuildservice/OWNERS b/pkg/clients/jvmbuildservice/OWNERS deleted file mode 100644 index 157f0e87a..000000000 --- a/pkg/clients/jvmbuildservice/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -reviewers: -- build-team diff --git a/pkg/clients/jvmbuildservice/artifact_builds.go b/pkg/clients/jvmbuildservice/artifact_builds.go deleted file mode 100644 index 3ba8a373b..000000000 --- a/pkg/clients/jvmbuildservice/artifact_builds.go +++ /dev/null @@ -1,18 +0,0 @@ -package jvmbuildservice - -import ( - "context" - - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ListArtifactBuilds returns a list of all artifactBuilds in a given namespace. -func (j *JvmbuildserviceController) ListArtifactBuilds(namespace string) (*v1alpha1.ArtifactBuildList, error) { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().ArtifactBuilds(namespace).List(context.Background(), metav1.ListOptions{}) -} - -// DeleteArtifactBuild removes an artifactBuild from a given namespace. -func (j *JvmbuildserviceController) DeleteArtifactBuild(name, namespace string) error { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().ArtifactBuilds(namespace).Delete(context.Background(), name, metav1.DeleteOptions{}) -} diff --git a/pkg/clients/jvmbuildservice/caches.go b/pkg/clients/jvmbuildservice/caches.go deleted file mode 100644 index e9cfa0b9a..000000000 --- a/pkg/clients/jvmbuildservice/caches.go +++ /dev/null @@ -1,37 +0,0 @@ -package jvmbuildservice - -import ( - "context" - "fmt" - "time" - - . "github.com/onsi/ginkgo/v2" - - "github.com/konflux-ci/e2e-tests/pkg/clients/common" - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - - v1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/util/wait" -) - -// WaitForCache waits for cache to exist. -func (j *JvmbuildserviceController) WaitForCache(commonctrl *common.SuiteController, testNamespace string) error { - return wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) { - cache, err := commonctrl.GetDeployment(v1alpha1.CacheDeploymentName, testNamespace) - if err != nil { - GinkgoWriter.Printf("failed to get JBS cache deployment: %s\n", err.Error()) - return false, nil - } - if cache.Status.AvailableReplicas > 0 { - GinkgoWriter.Printf("JBS cache is available\n") - return true, nil - } - for _, cond := range cache.Status.Conditions { - if cond.Type == v1.DeploymentProgressing && cond.Status == "False" { - return false, fmt.Errorf("JBS cache %s/%s deployment failed", testNamespace, v1alpha1.CacheDeploymentName) - } - } - GinkgoWriter.Printf("JBS cache %s/%s is progressing\n", testNamespace, v1alpha1.CacheDeploymentName) - return false, nil - }) -} diff --git a/pkg/clients/jvmbuildservice/controller.go b/pkg/clients/jvmbuildservice/controller.go deleted file mode 100644 index 776ca4183..000000000 --- a/pkg/clients/jvmbuildservice/controller.go +++ /dev/null @@ -1,15 +0,0 @@ -package jvmbuildservice - -import ( - kubeCl "github.com/konflux-ci/e2e-tests/pkg/clients/kubernetes" -) - -type JvmbuildserviceController struct { - *kubeCl.CustomClient -} - -func NewSuiteController(kube *kubeCl.CustomClient) (*JvmbuildserviceController, error) { - return &JvmbuildserviceController{ - kube, - }, nil -} diff --git a/pkg/clients/jvmbuildservice/dependency_builds.go b/pkg/clients/jvmbuildservice/dependency_builds.go deleted file mode 100644 index 26f1c3839..000000000 --- a/pkg/clients/jvmbuildservice/dependency_builds.go +++ /dev/null @@ -1,18 +0,0 @@ -package jvmbuildservice - -import ( - "context" - - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ListDependencyBuilds returns a list of all dependencyBuilds in a given namespace. -func (j *JvmbuildserviceController) ListDependencyBuilds(namespace string) (*v1alpha1.DependencyBuildList, error) { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().DependencyBuilds(namespace).List(context.Background(), metav1.ListOptions{}) -} - -// DeleteDependencyBuild removes a dependencyBuilds from a given namespace. -func (j *JvmbuildserviceController) DeleteDependencyBuild(name, namespace string) error { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().DependencyBuilds(namespace).Delete(context.Background(), name, metav1.DeleteOptions{}) -} diff --git a/pkg/clients/jvmbuildservice/jbs_configs.go b/pkg/clients/jvmbuildservice/jbs_configs.go deleted file mode 100644 index 38643c268..000000000 --- a/pkg/clients/jvmbuildservice/jbs_configs.go +++ /dev/null @@ -1,70 +0,0 @@ -package jvmbuildservice - -import ( - "context" - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - "github.com/redhat-appstudio/jvm-build-service/pkg/reconciler/jbsconfig" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// CreateJBSConfig creates a JBSConfig object. -func (j *JvmbuildserviceController) CreateJBSConfig(name, namespace string) (*v1alpha1.JBSConfig, error) { - config := &v1alpha1.JBSConfig{ - ObjectMeta: metav1.ObjectMeta{Name: name, Annotations: map[string]string{jbsconfig.DeleteImageRepositoryAnnotationName: "true"}}, - Spec: v1alpha1.JBSConfigSpec{ - EnableRebuilds: true, - RequireArtifactVerification: true, - MavenBaseLocations: map[string]string{ - "maven-repository-300-jboss": "https://repository.jboss.org/nexus/content/groups/public/", - "maven-repository-301-gradleplugins": "https://plugins.gradle.org/m2", - "maven-repository-302-confluent": "https://packages.confluent.io/maven", - "maven-repository-303-gradle": "https://repo.gradle.org/artifactory/libs-releases", - "maven-repository-304-eclipselink": "https://download.eclipse.org/rt/eclipselink/maven.repo", - "maven-repository-305-redhat": "https://maven.repository.redhat.com/ga", - "maven-repository-306-jitpack": "https://jitpack.io", - "maven-repository-307-jsweet": "https://repository.jsweet.org/artifactory/libs-release-local", - "maven-repository-308-jenkins": "https://repo.jenkins-ci.org/public/", - "maven-repository-309-spring-plugins": "https://repo.springsource.org/plugins-release", - "maven-repository-310-dokkadev": "https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev", - "maven-repository-311-ajoberstar": "https://ajoberstar.org/bintray-backup", - "maven-repository-312-googleandroid": "https://dl.google.com/dl/android/maven2/", - "maven-repository-313-kotlinnative14linux": "https://download.jetbrains.com/kotlin/native/builds/releases/1.4/linux", - "maven-repository-314-jcs": "https://packages.jetbrains.team/maven/p/jcs/maven", - "maven-repository-315-kotlin-bootstrap": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap/", - "maven-repository-315-kotlin-kotlin-dependencies": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies"}, - CacheSettings: v1alpha1.CacheSettings{ - RequestMemory: "256Mi", - RequestCPU: "100m", - Storage: "1Gi", - }, - BuildSettings: v1alpha1.BuildSettings{}, - RelocationPatterns: []v1alpha1.RelocationPatternElement{ - { - RelocationPattern: v1alpha1.RelocationPattern{ - BuildPolicy: "default", - Patterns: []v1alpha1.PatternElement{ - { - Pattern: v1alpha1.Pattern{ - From: "(io.github.stuartwdouglas.hacbs-test.simple):(simple-jdk17):(99-does-not-exist)", - To: "io.github.stuartwdouglas.hacbs-test.simple:simple-jdk17:0.1.2", - }, - }, - { - Pattern: v1alpha1.Pattern{ - From: "org.graalvm.sdk:graal-sdk:21.3.2", - To: "org.graalvm.sdk:graal-sdk:21.3.2.0-1-redhat-00001", - }, - }, - }, - }, - }, - }, - }, - } - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().JBSConfigs(namespace).Create(context.Background(), config, metav1.CreateOptions{}) -} - -// DeleteJBSConfig removes a JBSConfig from a given namespace. -func (j *JvmbuildserviceController) DeleteJBSConfig(name string, namespace string) error { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().JBSConfigs(namespace).Delete(context.Background(), name, metav1.DeleteOptions{}) -} diff --git a/pkg/clients/jvmbuildservice/rebuilt_artifacts.go b/pkg/clients/jvmbuildservice/rebuilt_artifacts.go deleted file mode 100644 index b1344e0a8..000000000 --- a/pkg/clients/jvmbuildservice/rebuilt_artifacts.go +++ /dev/null @@ -1,13 +0,0 @@ -package jvmbuildservice - -import ( - "context" - - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ListRebuiltArtifacts returns a list of all RebuiltArtifacts in a given namespace. -func (j *JvmbuildserviceController) ListRebuiltArtifacts(namespace string) (*v1alpha1.RebuiltArtifactList, error) { - return j.JvmbuildserviceClient().JvmbuildserviceV1alpha1().RebuiltArtifacts(namespace).List(context.Background(), metav1.ListOptions{}) -} diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index bba35b488..c5ad274cd 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -167,9 +167,6 @@ const ( QuayRepositorySecretName = "quay-repository" QuayRepositorySecretNamespace = "e2e-secrets" - JVMBuildImageSecretName = "jvm-build-image-secrets" - JBSConfigName = "jvm-build-config" - BuildPipelineConfigConfigMapYamlURL = "https://raw.githubusercontent.com/redhat-appstudio/infra-deployments/main/components/build-service/base/build-pipeline-config/build-pipeline-config.yaml" DefaultImagePushRepo = "quay.io/" + DefaultQuayOrg + "/test-images" diff --git a/pkg/framework/framework.go b/pkg/framework/framework.go index 096ba50c3..a35e805fb 100644 --- a/pkg/framework/framework.go +++ b/pkg/framework/framework.go @@ -15,7 +15,6 @@ import ( "github.com/konflux-ci/e2e-tests/pkg/clients/has" "github.com/konflux-ci/e2e-tests/pkg/clients/imagecontroller" "github.com/konflux-ci/e2e-tests/pkg/clients/integration" - "github.com/konflux-ci/e2e-tests/pkg/clients/jvmbuildservice" kubeCl "github.com/konflux-ci/e2e-tests/pkg/clients/kubernetes" "github.com/konflux-ci/e2e-tests/pkg/clients/release" "github.com/konflux-ci/e2e-tests/pkg/clients/tekton" @@ -25,14 +24,13 @@ import ( ) type ControllerHub struct { - HasController *has.HasController - CommonController *common.SuiteController - TektonController *tekton.TektonController - GitOpsController *gitops.GitopsController - ReleaseController *release.ReleaseController - IntegrationController *integration.IntegrationController - JvmbuildserviceController *jvmbuildservice.JvmbuildserviceController - ImageController *imagecontroller.ImageController + HasController *has.HasController + CommonController *common.SuiteController + TektonController *tekton.TektonController + GitOpsController *gitops.GitopsController + ReleaseController *release.ReleaseController + IntegrationController *integration.IntegrationController + ImageController *imagecontroller.ImageController } type Framework struct { @@ -201,12 +199,6 @@ func InitControllerHub(cc *kubeCl.CustomClient) (*ControllerHub, error) { return nil, err } - // Initialize JVM Build Service Controller - jvmbuildserviceController, err := jvmbuildservice.NewSuiteController(cc) - if err != nil { - return nil, err - } - // Initialize Image Controller imageController, err := imagecontroller.NewSuiteController(cc) if err != nil { @@ -214,13 +206,12 @@ func InitControllerHub(cc *kubeCl.CustomClient) (*ControllerHub, error) { } return &ControllerHub{ - HasController: hasController, - CommonController: commonCtrl, - TektonController: tektonController, - GitOpsController: gitopsController, - ReleaseController: releaseController, - IntegrationController: integrationController, - JvmbuildserviceController: jvmbuildserviceController, - ImageController: imageController, + HasController: hasController, + CommonController: commonCtrl, + TektonController: tektonController, + GitOpsController: gitopsController, + ReleaseController: releaseController, + IntegrationController: integrationController, + ImageController: imageController, }, nil } diff --git a/tests/build/jvm-build.go b/tests/build/jvm-build.go deleted file mode 100644 index 824b02d66..000000000 --- a/tests/build/jvm-build.go +++ /dev/null @@ -1,403 +0,0 @@ -package build - -import ( - "context" - "fmt" - "os" - "strings" - "time" - - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/devfile/library/v2/pkg/util" - appservice "github.com/konflux-ci/application-api/api/v1alpha1" - "github.com/konflux-ci/e2e-tests/pkg/clients/has" - "github.com/konflux-ci/e2e-tests/pkg/constants" - "github.com/konflux-ci/e2e-tests/pkg/framework" - "github.com/konflux-ci/e2e-tests/pkg/utils" - "github.com/konflux-ci/e2e-tests/pkg/utils/build" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/redhat-appstudio/jvm-build-service/openshift-with-appstudio-test/e2e" - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" - jvmclientSet "github.com/redhat-appstudio/jvm-build-service/pkg/client/clientset/versioned" - pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" - pipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - "k8s.io/client-go/kubernetes" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" -) - -var ( - testProjectGitUrl = utils.GetEnv("JVM_BUILD_SERVICE_TEST_REPO_URL", fmt.Sprintf("https://github.com/%s/hacbs-test-project", githubOrg)) - testProjectRevision = utils.GetEnv("JVM_BUILD_SERVICE_TEST_REPO_REVISION", "34da5a8f51fba6a8b7ec75a727d3c72ebb5e1274") -) - -// Marking the test as pending since jvm-build-service will be reworked with STONEBLD-2711 -var _ = framework.JVMBuildSuiteDescribe("JVM Build Service E2E tests", Label("jvm-build-service"), Pending, func() { - var f *framework.Framework - AfterEach(framework.ReportFailure(&f)) - var err error - - defer GinkgoRecover() - - var testNamespace, applicationName, componentName, pacBranchName, baseBranchName string - var component *appservice.Component - var timeout, interval time.Duration - var customJavaBuilderPipelineAnnotation map[string]string - - AfterAll(func() { - jvmClient := jvmclientSet.New(f.AsKubeAdmin.JvmbuildserviceController.JvmbuildserviceClient().JvmbuildserviceV1alpha1().RESTClient()) - tektonClient := pipelineclientset.New(f.AsKubeAdmin.TektonController.PipelineClient().TektonV1().RESTClient()) - kubeClient := kubernetes.New(f.AsKubeAdmin.CommonController.KubeInterface().CoreV1().RESTClient()) - //status report ends up in artifacts/redhat-appstudio-e2e/redhat-appstudio-e2e/artifacts/rp_preproc/attachments/xunit - e2e.GenerateStatusReport(testNamespace, jvmClient, kubeClient, tektonClient) - if !CurrentSpecReport().Failed() { - Expect(f.AsKubeAdmin.HasController.DeleteComponent(componentName, testNamespace, false)).To(Succeed()) - Expect(f.AsKubeAdmin.HasController.DeleteApplication(applicationName, testNamespace, false)).To(Succeed()) - Expect(f.AsKubeAdmin.TektonController.DeleteAllPipelineRunsInASpecificNamespace(testNamespace)).To(Succeed()) - Expect(f.SandboxController.DeleteUserSignup(f.UserName)).To(BeTrue()) - Expect(f.AsKubeAdmin.JvmbuildserviceController.DeleteJBSConfig(constants.JBSConfigName, testNamespace)).To(Succeed()) - } else { - Expect(f.AsKubeAdmin.CommonController.StoreAllPods(testNamespace)).To(Succeed()) - Expect(f.AsKubeAdmin.TektonController.StoreAllPipelineRuns(testNamespace)).To(Succeed()) - } - - // Delete new branches created by PaC and a testing branch used as a component's base branch - err = f.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(testProjectGitUrl), pacBranchName) - if err != nil { - Expect(err.Error()).To(ContainSubstring("Reference does not exist")) - } - err = f.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(testProjectGitUrl), baseBranchName) - if err != nil { - Expect(err.Error()).To(ContainSubstring("Reference does not exist")) - } - Expect(build.CleanupWebhooks(f, utils.GetRepoName(testProjectGitUrl))).ShouldNot(HaveOccurred()) - }) - - BeforeAll(func() { - f, err = framework.NewFramework(utils.GetGeneratedNamespace("jvm-build")) - Expect(err).NotTo(HaveOccurred()) - testNamespace = f.UserNamespace - Expect(testNamespace).NotTo(BeNil(), "failed to create sandbox user namespace") - - _, err = f.AsKubeAdmin.JvmbuildserviceController.CreateJBSConfig(constants.JBSConfigName, testNamespace) - Expect(err).ShouldNot(HaveOccurred()) - - //wait for the cache - - Expect(f.AsKubeAdmin.JvmbuildserviceController.WaitForCache(f.AsKubeAdmin.CommonController, testNamespace)).Should(Succeed()) - - customJavaPipelineBundleRef := os.Getenv(constants.CUSTOM_JAVA_PIPELINE_BUILD_BUNDLE_ENV) - if len(customJavaPipelineBundleRef) > 0 { - customJavaBuilderPipelineAnnotation = map[string]string{ - "build.appstudio.openshift.io/pipeline": fmt.Sprintf(`{"name":"java-builder", "bundle": "%s"}`, customJavaPipelineBundleRef), - } - } - - timeout = time.Minute * 20 - interval = time.Second * 10 - - applicationName = fmt.Sprintf("jvm-build-suite-application-%s", util.GenerateRandomString(4)) - _, err = f.AsKubeAdmin.HasController.CreateApplication(applicationName, testNamespace) - Expect(err).NotTo(HaveOccurred()) - - componentName = fmt.Sprintf("jvm-build-suite-component-%s", util.GenerateRandomString(6)) - - pacBranchName = constants.PaCPullRequestBranchPrefix + componentName - baseBranchName = fmt.Sprintf("base-%s", util.GenerateRandomString(6)) - - err = f.AsKubeAdmin.CommonController.Github.CreateRef(utils.GetRepoName(testProjectGitUrl), "main", testProjectRevision, baseBranchName) - Expect(err).ShouldNot(HaveOccurred()) - - // Create a component with Git Source URL being defined - componentObj := appservice.ComponentSpec{ - ComponentName: componentName, - Source: appservice.ComponentSource{ - ComponentSourceUnion: appservice.ComponentSourceUnion{ - GitSource: &appservice.GitSource{ - URL: testProjectGitUrl, - Revision: baseBranchName, - }, - }, - }, - } - component, err = f.AsKubeAdmin.HasController.CreateComponent(componentObj, testNamespace, "", "", applicationName, true, utils.MergeMaps(constants.ComponentPaCRequestAnnotation, customJavaBuilderPipelineAnnotation)) - Expect(err).ShouldNot(HaveOccurred()) - }) - - When("the Component with s2i-java component is created", func() { - It("a PipelineRun is triggered", func() { - Eventually(func() error { - pr, err := f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, "") - if err != nil { - GinkgoWriter.Printf("PipelineRun has not been created yet for the component %s/%s", testNamespace, componentName) - return err - } - if !pr.HasStarted() { - return fmt.Errorf("pipelinerun %s/%s hasn't started yet", pr.GetNamespace(), pr.GetName()) - } - return nil - }, timeout, constants.PipelineRunPollingInterval).Should(Succeed(), fmt.Sprintf("timed out when waiting for the PipelineRun to start for the component %s/%s", testNamespace, componentName)) - }) - - It("the build-container task from component pipelinerun references a correct analyzer image", func() { - ciAnalyzerImage := os.Getenv("JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE") - matchingTaskStep := "analyse-dependencies-java-sbom" - - if ciAnalyzerImage == "" { - Skip("JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE env var is not exported, skipping the test...") - } - - Eventually(func() error { - pr, err := f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, "") - Expect(err).ShouldNot(HaveOccurred()) - - for _, chr := range pr.Status.ChildReferences { - taskRun := &pipeline.TaskRun{} - taskRunKey := types.NamespacedName{Namespace: pr.Namespace, Name: chr.Name} - err := f.AsKubeAdmin.CommonController.KubeRest().Get(context.Background(), taskRunKey, taskRun) - Expect(err).ShouldNot(HaveOccurred()) - - prTrStatus := &pipeline.PipelineRunTaskRunStatus{ - PipelineTaskName: chr.PipelineTaskName, - Status: &taskRun.Status, - } - - if chr.PipelineTaskName == constants.BuildTaskRunName && prTrStatus.Status != nil && prTrStatus.Status.TaskSpec != nil && prTrStatus.Status.TaskSpec.Steps != nil { - for _, step := range prTrStatus.Status.TaskSpec.Steps { - if step.Name == matchingTaskStep { - if step.Image != ciAnalyzerImage { - Fail(fmt.Sprintf("the build-container task from component pipelinerun doesn't reference the correct request processor image. expected: %v, actual: %v", ciAnalyzerImage, step.Image)) - } else { - return nil - } - } - } - } - } - return fmt.Errorf("couldn't find a matching step %s in task %s in PipelineRun %s/%s", matchingTaskStep, constants.BuildTaskRunName, testNamespace, pr.GetName()) - }, timeout, interval).Should(Succeed(), "timed out when verifying the request processor image reference in pipelinerun") - }) - - It("that PipelineRun completes successfully", func() { - Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component, "", - f.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true}, nil)).To(Succeed()) - - pr, err := f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, "") - Expect(err).ShouldNot(HaveOccurred()) - //now delete it so it can't interfere with later test logic - Expect(f.AsKubeAdmin.TektonController.DeletePipelineRun(pr.Name, testNamespace)).Should(Succeed()) - }) - - It("artifactbuilds and dependencybuilds are generated", func() { - Eventually(func() bool { - var gotABs, gotDBs bool - abList, err := f.AsKubeAdmin.JvmbuildserviceController.ListArtifactBuilds(testNamespace) - if err != nil { - GinkgoWriter.Printf("error listing artifactbuilds: %s\n", err.Error()) - return false - } - if len(abList.Items) > 0 { - gotABs = true - } - dbList, err := f.AsKubeAdmin.JvmbuildserviceController.ListDependencyBuilds(testNamespace) - if err != nil { - GinkgoWriter.Printf("error listing dependencybuilds: %s\n", err.Error()) - return false - } - if len(dbList.Items) > 0 { - gotDBs = true - } - GinkgoWriter.Printf("got artifactbuilds: %t, got dependencybuilds: %t\n", gotABs, gotDBs) - if !gotABs || !gotDBs { - return false - } - return true - }, timeout, interval).Should(BeTrue(), "timed out when waiting for the generation of artifactbuilds and dependencybuilds") - }) - - It("some artifactbuilds and dependencybuilds complete", func() { - Eventually(func() bool { - var abComplete, dbComplete bool - abList, err := f.AsKubeAdmin.JvmbuildserviceController.ListArtifactBuilds(testNamespace) - if err != nil { - GinkgoWriter.Printf("error listing artifactbuilds: %s\n", err.Error()) - return false - } - for _, ab := range abList.Items { - if ab.Status.State == v1alpha1.ArtifactBuildStateComplete { - abComplete = true - break - } - } - dbList, err := f.AsKubeAdmin.JvmbuildserviceController.ListDependencyBuilds(testNamespace) - if err != nil { - GinkgoWriter.Printf("error listing dependencybuilds: %s\n", err.Error()) - return false - } - for _, db := range dbList.Items { - if db.Status.State == v1alpha1.DependencyBuildStateComplete { - dbComplete = true - break - } - } - GinkgoWriter.Printf("some artifactbuilds completed: %t, some dependencybuilds completed: %t\n", abComplete, dbComplete) - if !abComplete || !dbComplete { - return false - } - return true - }, timeout, interval).Should(BeTrue(), fmt.Sprintf("timed out when waiting for some artifactbuilds and dependencybuilds to complete in %s namespace", testNamespace)) - }) - - It("all artifactbuild and dependencybuilds complete", func() { - Eventually(func() bool { - abList, err := f.AsKubeAdmin.JvmbuildserviceController.ListArtifactBuilds(testNamespace) - Expect(err).ShouldNot(HaveOccurred(), "error in listing artifact builds") - // we want to make sure there is more than one ab and that they are all complete - allAbCompleted := len(abList.Items) > 0 - GinkgoWriter.Printf("number of artifactbuilds: %d\n", len(abList.Items)) - for _, ab := range abList.Items { - if ab.Status.State != v1alpha1.ArtifactBuildStateComplete { - GinkgoWriter.Printf("artifactbuild %s not complete\n", ab.Spec.GAV) - allAbCompleted = false - break - } - } - dbList, err := f.AsKubeAdmin.JvmbuildserviceController.ListDependencyBuilds(testNamespace) - Expect(err).ShouldNot(HaveOccurred(), "error in listing dependency builds") - allDbCompleted := len(dbList.Items) > 0 - GinkgoWriter.Printf("number of dependencybuilds: %d\n", len(dbList.Items)) - for _, db := range dbList.Items { - if db.Status.State != v1alpha1.DependencyBuildStateComplete { - GinkgoWriter.Printf("dependencybuild %s not complete\n", db.Spec.ScmInfo.SCMURL) - allDbCompleted = false - break - } else if db.Status.State == v1alpha1.DependencyBuildStateFailed { - Fail(fmt.Sprintf("dependencybuild %s FAILED", db.Spec.ScmInfo.SCMURL)) - } - } - if allAbCompleted && allDbCompleted { - return true - } - return false - }, 2*timeout, interval).Should(BeTrue(), fmt.Sprintf("timed out when waiting for all artifactbuilds and dependencybuilds to complete in %s namespace", testNamespace)) - }) - - It("does rebuild using cached dependencies", func() { - prun := &pipeline.PipelineRun{} - - component, err := f.AsKubeAdmin.HasController.GetComponent(componentName, testNamespace) - Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("could not get component %s/%s", testNamespace, componentName)) - - annotations := utils.MergeMaps(component.GetAnnotations(), constants.ComponentTriggerSimpleBuildAnnotation) - component.SetAnnotations(annotations) - Expect(f.AsKubeAdmin.CommonController.KubeRest().Update(context.Background(), component, &client.UpdateOptions{})).To(Succeed()) - - Eventually(func() error { - prun, err = f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, "") - return err - }, 1*time.Minute, constants.PipelineRunPollingInterval).Should(BeNil(), fmt.Sprintf("timed out when getting the pipelinerun for %s/%s component", testNamespace, componentName)) - - ctx := context.Background() - - watch, err := f.AsKubeAdmin.TektonController.GetPipelineRunWatch(ctx, testNamespace) - Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("watch pipelinerun failed in %s namespace", testNamespace)) - - exitForLoop := false - - for { - select { - case <-time.After(15 * time.Minute): - Fail(fmt.Sprintf("timed out waiting for second build to complete in %s namespace", testNamespace)) - case event := <-watch.ResultChan(): - if event.Object == nil { - continue - } - pr, ok := event.Object.(*pipeline.PipelineRun) - if !ok { - continue - } - if prun.Name != pr.Name { - if pr.IsDone() { - GinkgoWriter.Printf("got event for pipelinerun %s in a terminal state\n", pr.GetName()) - continue - } - Fail(fmt.Sprintf("another non-completed pipeline run %s/%s was generated when it should not", pr.GetNamespace(), pr.GetName())) - } - GinkgoWriter.Printf("done processing event for pr %s\n", pr.GetName()) - if pr.IsDone() { - GinkgoWriter.Println("pr is done") - - podClient := f.AsKubeAdmin.CommonController.KubeInterface().CoreV1().Pods(testNamespace) - listOptions := metav1.ListOptions{ - LabelSelector: fmt.Sprintf("tekton.dev/pipelineRun=%s", pr.GetName()), - } - podList, err := podClient.List(context.Background(), listOptions) - Expect(err).ShouldNot(HaveOccurred(), "error listing pr pods") - - pods := podList.Items - - if len(pods) == 0 { - Fail(fmt.Sprintf("pod for pipeline run %s/%s unexpectedly missing", pr.GetNamespace(), pr.GetName())) - } - - containers := []corev1.Container{} - containers = append(containers, pods[0].Spec.InitContainers...) - containers = append(containers, pods[0].Spec.Containers...) - - for _, container := range containers { - if !strings.Contains(container.Name, "analyse-dependecies") { - continue - } - cLog, err := utils.GetContainerLogs(f.AsKubeAdmin.CommonController.KubeInterface(), pods[0].Name, container.Name, testNamespace) - Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("getting container logs for %s container from %s pod in %s namespace failed", container.Name, pods[0].GetName(), testNamespace)) - if strings.Contains(cLog, "\"publisher\" : \"central\"") { - Fail(fmt.Sprintf("pipelinerun %s has container %s with dep analysis still pointing to central %s", pr.Name, container.Name, cLog)) - } - if !strings.Contains(cLog, "\"publisher\" : \"rebuilt\"") { - Fail(fmt.Sprintf("pipelinerun %s has container %s with dep analysis that does not access rebuilt %s", pr.Name, container.Name, cLog)) - } - if !strings.Contains(cLog, "\"java:scm-uri\" : \"https://github.com/stuartwdouglas/hacbs-test-simple-jdk8.git\"") { - Fail(fmt.Sprintf("pipelinerun %s has container %s with dep analysis did not include java:scm-uri %s", pr.Name, container.Name, cLog)) - } - if !strings.Contains(cLog, "\"java:scm-commit\" : \"") { - Fail(fmt.Sprintf("pipelinerun %s has container %s with dep analysis did not include java:scm-commit %s", pr.Name, container.Name, cLog)) - } - break - } - GinkgoWriter.Println("pr is done and has correct analyse-dependecies output, exiting") - exitForLoop = true - } - } - if exitForLoop { - break - } - } - }) - - It("All rebuilt images are signed and attested", func() { - seen := map[string]bool{} - rebuilt, err := f.AsKubeAdmin.JvmbuildserviceController.ListRebuiltArtifacts(testNamespace) - Expect(err).NotTo(HaveOccurred()) - for _, i := range rebuilt.Items { - if seen[i.Spec.Image] { - continue - } - seen[i.Spec.Image] = true - - imageWithDigest := i.Spec.Image + "@" + i.Spec.Digest - - Expect(f.AsKubeAdmin.TektonController.AwaitAttestationAndSignature(imageWithDigest, constants.ChainsAttestationTimeout)).To( - Succeed(), - "Could not find .att or .sig ImageStreamTags within the 1 minute timeout. "+ - "Most likely the chains-controller did not create those in time. "+ - "Look at the chains-controller logs.") - GinkgoWriter.Printf("Cosign verify pass with .att and .sig ImageStreamTags found for %s\n", imageWithDigest) - - } - }) - }) -}) diff --git a/tests/konflux-demo/konflux-demo.go b/tests/konflux-demo/konflux-demo.go index 87914254d..00f17fae6 100644 --- a/tests/konflux-demo/konflux-demo.go +++ b/tests/konflux-demo/konflux-demo.go @@ -10,11 +10,6 @@ import ( buildcontrollers "github.com/konflux-ci/build-service/controllers" tektonutils "github.com/konflux-ci/release-service/tekton/utils" - "github.com/redhat-appstudio/jvm-build-service/openshift-with-appstudio-test/e2e" - jvmclientSet "github.com/redhat-appstudio/jvm-build-service/pkg/client/clientset/versioned" - pipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - "k8s.io/client-go/kubernetes" - "github.com/devfile/library/v2/pkg/util" ecp "github.com/enterprise-contract/enterprise-contract-controller/api/v1alpha1" "github.com/google/go-github/v44/github" @@ -27,7 +22,6 @@ import ( "github.com/konflux-ci/e2e-tests/pkg/utils/tekton" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -99,11 +93,6 @@ var _ = framework.KonfluxDemoSuiteDescribe(Label(devEnvTestLabel), func() { createReleaseConfig(*fw, managedNamespace, appSpec.ComponentSpec.Name, appSpec.ApplicationName, sharedSecret.Data[".dockerconfigjson"]) - // JBS related config - _, err = fw.AsKubeAdmin.JvmbuildserviceController.CreateJBSConfig(constants.JBSConfigName, fw.UserNamespace) - Expect(err).ShouldNot(HaveOccurred()) - Expect(fw.AsKubeAdmin.JvmbuildserviceController.WaitForCache(fw.AsKubeAdmin.CommonController, fw.UserNamespace)).Should(Succeed()) - // get the build pipeline bundle annotation buildPipelineAnnotation = build.GetDockerBuildPipelineBundle() @@ -382,34 +371,6 @@ var _ = framework.KonfluxDemoSuiteDescribe(Label(devEnvTestLabel), func() { }, customResourceUpdateTimeout, defaultPollingInterval).Should(Succeed(), fmt.Sprintf("failed to see release %q in namespace %q get marked as released", release.Name, fw.UserNamespace)) }) }) - - When("JVM Build Service is used for rebuilding dependencies", func() { - // Marking the step as pending since jvm-build-service will be reworked with STONEBLD-2711 - It("should eventually rebuild of all artifacts and dependencies successfully", Pending, func() { - jvmClient := jvmclientSet.New(fw.AsKubeAdmin.JvmbuildserviceController.JvmbuildserviceClient().JvmbuildserviceV1alpha1().RESTClient()) - tektonClient := pipelineclientset.New(fw.AsKubeAdmin.TektonController.PipelineClient().TektonV1beta1().RESTClient()) - kubeClient := kubernetes.New(fw.AsKubeAdmin.CommonController.KubeInterface().CoreV1().RESTClient()) - //status report ends up in artifacts/redhat-appstudio-e2e/redhat-appstudio-e2e/artifacts/rp_preproc/attachments/xunit - defer e2e.GenerateStatusReport(fw.UserNamespace, jvmClient, kubeClient, tektonClient) - Eventually(func() error { - abList, err := fw.AsKubeAdmin.JvmbuildserviceController.ListArtifactBuilds(fw.UserNamespace) - Expect(err).ShouldNot(HaveOccurred()) - for _, ab := range abList.Items { - if ab.Status.State != v1alpha1.ArtifactBuildStateComplete { - return fmt.Errorf("artifactbuild %s not complete", ab.Spec.GAV) - } - } - dbList, err := fw.AsKubeAdmin.JvmbuildserviceController.ListDependencyBuilds(fw.UserNamespace) - Expect(err).ShouldNot(HaveOccurred()) - for _, db := range dbList.Items { - if db.Status.State != v1alpha1.DependencyBuildStateComplete { - return fmt.Errorf("dependencybuild %s not complete", db.Spec.ScmInfo.SCMURL) - } - } - return nil - }, jvmRebuildTimeout, jvmRebuildPollingInterval).Should(Succeed(), fmt.Sprintf("timed out when waiting for all artifactbuilds and dependencybuilds to complete in namespace %q", fw.UserNamespace)) - }) - }) }) } })