// validateBuildRunToFail creates the build run and watches its flow until it fails
// and verifies the reason using a regular expression.
validateBuildRunToFail creates the build run and watches its flow until it fails
and verifies the reason using a regular expression.
// validateBuildRunToFail creates the build run and watches its flow until it fails // and verifies the reason using a regular expression .
func validateBuildRunToFail(
	ctx *framework.Context,
	namespace string,
	testBuildRun *operator.BuildRun,
	expectedMessageRegexp string,
	timeout time.Duration,
	retry time.Duration,
) {
	f := framework.Global
	trueCondition := corev1.ConditionTrue
	falseCondition := corev1.ConditionFalse
	err := f.Client.Create(goctx.TODO(), testBuildRun, cleanupOptions(ctx, timeout, retry))
	Expect(err).ToNot(HaveOccurred(), "Failed to create build run.")
	buildRunNsName := types.NamespacedName{Name: testBuildRun.Name, Namespace: namespace}
	nextStatusLog := time.Now().Add(60 * time.Second)
	Eventually(func() corev1.ConditionStatus {
		err = clientGet(buildRunNsName, testBuildRun)
		Expect(err).ToNot(HaveOccurred(), "Error retrieving build run")
		if testBuildRun.Status.GetCondition(operator.Succeeded) == nil {
			return corev1.ConditionUnknown
		}
		Expect(testBuildRun.Status.GetCondition(operator.Succeeded).Status).ToNot(Equal(trueCondition))
		now := time.Now()
		if now.After(nextStatusLog) {
			Logf("Still waiting for build run '%s' to fail.", testBuildRun.Name)
			nextStatusLog = time.Now().Add(60 * time.Second)
		}
		return testBuildRun.Status.GetCondition(operator.Succeeded).Status
	}, time.Duration(550*getTimeoutMultiplier())*time.Second, 5*time.Second).Should(Equal(falseCondition), "BuildRun did not fail")
	Expect(testBuildRun.Status.BuildSpec).ToNot(BeNil())
	Expect(testBuildRun.Status.GetCondition(operator.Succeeded).Message).To(MatchRegexp(expectedMessageRegexp))
}
func validateBuildRunToFail ( ctx * framework . Context , namespace string , testBuildRun * operator . BuildRun , expectedMessageRegexp string , timeout time . Duration , retry time . Duration , ) { f := framework . Global trueCondition := corev1 . ConditionTrue falseCondition := corev1 . ConditionFalse err := f . Client . Create ( goctx . TODO ( ) , testBuildRun , cleanupOptions ( ctx , timeout , retry ) ) Expect ( err ) . ToNot ( HaveOccurred ( ) , " " ) buildRunNsName := types . NamespacedName { Name : testBuildRun . Name , Namespace : namespace } nextStatusLog := time . Now ( ) . Add ( 60 * time . Second ) Eventually ( func ( ) corev1 . ConditionStatus { err = clientGet ( buildRunNsName , testBuildRun ) Expect ( err ) . ToNot ( HaveOccurred ( ) , " " ) if testBuildRun . Status . GetCondition ( operator . Succeeded ) == nil { return corev1 . ConditionUnknown } Expect ( testBuildRun . Status . GetCondition ( operator . Succeeded ) . Status ) . ToNot ( Equal ( trueCondition ) ) now := time . Now ( ) if now . After ( nextStatusLog ) { Logf ( " " , testBuildRun . Name ) nextStatusLog = time . Now ( ) . Add ( 60 * time . Second ) } return testBuildRun . Status . GetCondition ( operator . Succeeded ) . Status } , time . Duration ( 550 * getTimeoutMultiplier ( ) ) * time . Second , 5 * time . Second ) . Should ( Equal ( falseCondition ) , " " ) Expect ( testBuildRun . Status . BuildSpec ) . ToNot ( BeNil ( ) ) Expect ( testBuildRun . Status . GetCondition ( operator . Succeeded ) . Message ) . To ( MatchRegexp ( expectedMessageRegexp ) ) }
validateBuildRunToFail creates the build run and watches its flow until it fails
and verifies the reason using a regular expression.
validateBuildRunToFail creates the build run and watches its flow until it fails and verifies the reason using a regular expression .
// Create the BuildRun // Ensure that eventually the BuildRun moves to Failed. // Verify that the BuildSpec is available in the status // Verify the build run failure