Skip to content

Commit 63ced54

Browse files
committed
Fix tests
1 parent c824577 commit 63ced54

File tree

4 files changed

+54
-48
lines changed

4 files changed

+54
-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: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,14 @@ func getBuildPipelineNo(client runtimeclient.Client, g *WithT, no int) *tektonpi
287287
return &build
288288
}
289289

290+
/*
290291
func getDeployPipeline(client runtimeclient.Client, g *WithT) *tektonpipeline.PipelineRun {
291292
ctx := context.TODO()
292293
build := tektonpipeline.PipelineRun{}
293294
g.Expect(client.Get(ctx, types.NamespacedName{Namespace: metav1.NamespaceDefault, Name: "test-deploy"}, &build)).Should(BeNil())
294295
return &build
295296
}
297+
*/
296298

297299
func getBuildInfoPipeline(client runtimeclient.Client, g *WithT) *tektonpipeline.PipelineRun {
298300
return getBuildInfoPipelineNo(client, g, 0)
@@ -380,65 +382,67 @@ func TestStateBuilding(t *testing.T) {
380382
setup(g)
381383
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
382384

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

398400
g.Expect(db.Status.DeployedArtifacts).Should(ContainElement(TestArtifact))
399401
ra := v1alpha1.RebuiltArtifact{}
400402
g.Expect(client.Get(ctx, types.NamespacedName{Name: artifactbuild.CreateABRName(TestArtifact), Namespace: metav1.NamespaceDefault}, &ra)).Should(Succeed())
401403
g.Expect(ra.Spec.GAV).Should(Equal(TestArtifact))
402404
g.Expect(ra.Spec.Image).ShouldNot(BeNil())
403-
pr = getBuildPipeline(client, g)
405+
pr := getBuildPipeline(client, g)
404406
g.Expect(len(pr.Finalizers)).Should(Equal(1))
405407

406408
g.Expect(client.Delete(ctx, pr)).Should(BeNil())
407409
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Namespace: db.Namespace, Name: pr.Name}}))
408410
g.Expect(client.Get(ctx, types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}, pr)).ShouldNot(Succeed())
409411
})
412+
// TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
413+
/*
414+
t.Run("Test reconcile building DependencyBuild with failed deploy pipeline", func(t *testing.T) {
415+
g := NewGomegaWithT(t)
416+
setup(g)
417+
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
418+
419+
pr := getDeployPipeline(client, g)
420+
pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
421+
pr.Status.SetCondition(&apis.Condition{
422+
Type: apis.ConditionSucceeded,
423+
Status: "False",
424+
LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
425+
})
426+
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
427+
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
428+
db := getBuild(client, g)
429+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
410430
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()}},
422431
})
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))
427432
428-
})
433+
t.Run("Test reconcile building DependencyBuild with deleted deploy pipeline", func(t *testing.T) {
434+
g := NewGomegaWithT(t)
435+
setup(g)
436+
runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
429437
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)
438+
pr := getDeployPipeline(client, g)
439+
g.Expect(client.Delete(ctx, pr)).Should(Succeed())
440+
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
441+
db := getBuild(client, g)
442+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
434443
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-
})
444+
})
445+
*/
442446
t.Run("Test reconcile building DependencyBuild with failed pipeline", func(t *testing.T) {
443447
g := NewGomegaWithT(t)
444448
setup(g)
@@ -583,7 +587,7 @@ func runSuccessfulBuild(g *WithT, client runtimeclient.Client, ctx context.Conte
583587
g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
584588
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: taskRunName}))
585589
db := getBuild(client, g)
586-
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateDeploying))
590+
g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateComplete))
587591
g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: db.Name, Namespace: db.Namespace}}))
588592
}
589593

0 commit comments

Comments
 (0)