Skip to content

Commit 2f76be3

Browse files
committed
Fix tests
1 parent f9cb3b5 commit 2f76be3

File tree

4 files changed

+52
-48
lines changed

4 files changed

+52
-48
lines changed

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/BuildVerifyCommand.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ public class BuildVerifyCommand implements Runnable {
5353
@CommandLine.Option(names = "--task-run-name")
5454
String taskRun;
5555

56-
@CommandLine.Option(names = "--logs-path")
57-
Path logsPath;
58-
5956
@CommandLine.Option(required = true, names = "--scm-uri")
6057
String scmUri;
6158

pkg/reconciler/dependencybuild/buildrecipeyaml.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ var buildEntryScript string
5555
//go:embed scripts/Dockerfile.build-trusted-artifacts
5656
var buildTrustedArtifacts string
5757

58+
// TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
59+
/*
5860
func createDeployPipelineSpec(jbsConfig *v1alpha1.JBSConfig, buildRequestProcessorImage string) (*tektonpipeline.PipelineSpec, error) {
5961
// Original deploy pipeline used to run maven deployment and also tag the images using 'oras tag'
6062
// with the SHA256 encoded sum of the GAVs.
@@ -129,6 +131,8 @@ func createDeployPipelineSpec(jbsConfig *v1alpha1.JBSConfig, buildRequestProcess
129131
}
130132
return ps, nil
131133
}
134+
*/
135+
132136
func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfig *v1alpha1.JBSConfig, systemConfig *v1alpha1.SystemConfig, recipe *v1alpha1.BuildRecipe, db *v1alpha1.DependencyBuild, paramValues []tektonpipeline.Param, buildRequestProcessorImage string, buildId string, existingImages map[string]string, orasOptions string) (*tektonpipeline.PipelineSpec, string, error) {
133137

134138
// Rather than tagging with hash of json build recipe, buildrequestprocessor image and db.Name as the former two
@@ -138,8 +142,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
138142
verifyBuiltArtifactsArgs := verifyParameters(jbsConfig, recipe)
139143
deployArgs := []string{
140144
"verify",
141-
fmt.Sprintf("--path=%s/artifacts", PostBuildVolumeMount),
142-
fmt.Sprintf("--logs-path=%s/logs", PostBuildVolumeMount),
145+
fmt.Sprintf("--path=%s/deployment", PostBuildVolumeMount),
143146
"--task-run-name=$(context.taskRun.name)",
144147
"--build-id=" + buildId,
145148
"--scm-uri=" + db.Spec.ScmInfo.SCMURL,
@@ -561,7 +564,7 @@ URL=%s
561564
DIGEST=$(tasks.%s.results.IMAGE_DIGEST)
562565
AARCHIVE=$(oras manifest fetch $ORAS_OPTIONS $URL@$DIGEST | jq --raw-output '.layers[0].digest')
563566
echo "URL $URL DIGEST $DIGEST AARCHIVE $AARCHIVE"
564-
use-archive oci:$URL@$AARCHIVE=%s/artifacts`, orasOptions, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName, PostBuildVolumeMount),
567+
use-archive oci:$URL@$AARCHIVE=%s`, orasOptions, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName, PostBuildVolumeMount),
565568
},
566569
{
567570
Name: "verify-and-check-for-contaminates",
@@ -856,7 +859,7 @@ func verifyParameters(jbsConfig *v1alpha1.JBSConfig, recipe *v1alpha1.BuildRecip
856859
verifyBuiltArtifactsArgs := []string{
857860
"verify-built-artifacts",
858861
"--repository-url=$(params." + PipelineParamProxyUrl + ")",
859-
fmt.Sprintf("--deploy-path=%s/artifacts", PostBuildVolumeMount),
862+
fmt.Sprintf("--deploy-path=%s/deployment", PostBuildVolumeMount),
860863
"--task-run-name=$(context.taskRun.name)",
861864
"--results-file=$(results." + PipelineResultPassedVerification + ".path)",
862865
}

pkg/reconciler/dependencybuild/dependencybuild.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ func (r *ReconcileDependencyBuild) removePipelineFinalizer(ctx context.Context,
13631363
}
13641364

13651365
// TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
1366+
/*
13661367
func (r *ReconcileDependencyBuild) handleStateDeploying(ctx context.Context, db *v1alpha1.DependencyBuild) (reconcile.Result, error) {
13671368
log, _ := logr.FromContext(ctx)
13681369
//first we check to see if the pipeline exists
@@ -1498,6 +1499,7 @@ func (r *ReconcileDependencyBuild) handleDeployPipelineRunReceived(ctx context.C
14981499
}
14991500
return reconcile.Result{}, nil
15001501
}
1502+
*/
15011503

15021504
// This is to remove any '#xxx' fragment from a URI so that git clone commands don't need separate adjustment
15031505
func modifyURLFragment(log logr.Logger, scmURL string) string {

pkg/reconciler/dependencybuild/dependencybuild_test.go

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -380,65 +380,67 @@ func TestStateBuilding(t *testing.T) {
380380
setup(g)
381381
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
382382

383-
pr := getDeployPipeline(client, g)
384-
pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
385-
pr.Status.SetCondition(&apis.Condition{
386-
Type: apis.ConditionSucceeded,
387-
Status: "True",
388-
LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
389-
})
390-
pr.Status.Results = []tektonpipeline.PipelineRunResult{{Name: PipelineResultDeployedResources, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: TestArtifact}}}
391-
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
383+
//pr := getDeployPipeline(client, g)
384+
//pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
385+
//pr.Status.SetCondition(&apis.Condition{
386+
// Type: apis.ConditionSucceeded,
387+
// Status: "True",
388+
// LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
389+
//})
390+
//pr.Status.Results = []tektonpipeline.PipelineRunResult{{Name: PipelineResultDeployedResources, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: TestArtifact}}}
391+
//g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
392+
//db := getBuild(client, g)
393+
//g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
394+
//g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: db.Name, Namespace: db.Namespace}}))
392395
db := getBuild(client, g)
393-
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
394-
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: db.Name, Namespace: db.Namespace}}))
395-
db = getBuild(client, g)
396396
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateComplete))
397397

398398
g.Expect(db.Status.DeployedArtifacts).Should(ContainElement(TestArtifact))
399399
ra := v1alpha1.RebuiltArtifact{}
400400
g.Expect(client.Get(ctx, types.NamespacedName{Name: artifactbuild.CreateABRName(TestArtifact), Namespace: metav1.NamespaceDefault}, &ra)).Should(Succeed())
401401
g.Expect(ra.Spec.GAV).Should(Equal(TestArtifact))
402402
g.Expect(ra.Spec.Image).ShouldNot(BeNil())
403-
pr = getBuildPipeline(client, g)
403+
pr := getBuildPipeline(client, g)
404404
g.Expect(len(pr.Finalizers)).Should(Equal(1))
405405

406406
g.Expect(client.Delete(ctx, pr)).Should(BeNil())
407407
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Namespace: db.Namespace, Name: pr.Name}}))
408408
g.Expect(client.Get(ctx, types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}, pr)).ShouldNot(Succeed())
409409
})
410+
// TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
411+
/*
412+
t.Run("Test reconcile building DependencyBuild with failed deploy pipeline", func(t *testing.T) {
413+
g := NewGomegaWithT(t)
414+
setup(g)
415+
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
416+
417+
pr := getDeployPipeline(client, g)
418+
pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
419+
pr.Status.SetCondition(&apis.Condition{
420+
Type: apis.ConditionSucceeded,
421+
Status: "False",
422+
LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
423+
})
424+
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
425+
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
426+
db := getBuild(client, g)
427+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
410428
411-
t.Run("Test reconcile building DependencyBuild with failed deploy pipeline", func(t *testing.T) {
412-
g := NewGomegaWithT(t)
413-
setup(g)
414-
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
415-
416-
pr := getDeployPipeline(client, g)
417-
pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
418-
pr.Status.SetCondition(&apis.Condition{
419-
Type: apis.ConditionSucceeded,
420-
Status: "False",
421-
LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
422429
})
423-
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
424-
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
425-
db := getBuild(client, g)
426-
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
427430
428-
})
431+
t.Run("Test reconcile building DependencyBuild with deleted deploy pipeline", func(t *testing.T) {
432+
g := NewGomegaWithT(t)
433+
setup(g)
434+
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
429435
430-
t.Run("Test reconcile building DependencyBuild with deleted deploy pipeline", func(t *testing.T) {
431-
g := NewGomegaWithT(t)
432-
setup(g)
433-
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
436+
pr := getDeployPipeline(client, g)
437+
g.Expect(client.Delete(ctx, pr)).Should(Succeed())
438+
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
439+
db := getBuild(client, g)
440+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
434441
435-
pr := getDeployPipeline(client, g)
436-
g.Expect(client.Delete(ctx, pr)).Should(Succeed())
437-
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
438-
db := getBuild(client, g)
439-
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
440-
441-
})
442+
})
443+
*/
442444
t.Run("Test reconcile building DependencyBuild with failed pipeline", func(t *testing.T) {
443445
g := NewGomegaWithT(t)
444446
setup(g)
@@ -583,7 +585,7 @@ func runSuccessfulBuild(g *WithT, client runtimeclient.Client, ctx context.Conte
583585
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
584586
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: taskRunName}))
585587
db := getBuild(client, g)
586-
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateDeploying))
588+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateComplete))
587589
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: db.Name, Namespace: db.Namespace}}))
588590
}
589591

0 commit comments

Comments
 (0)