Skip to content

Commit

Permalink
Fix some tests due to code changes between the initial PR and now
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester committed Oct 5, 2022
1 parent 2357bd6 commit 96b82bc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 43 deletions.
28 changes: 8 additions & 20 deletions pkg/pod/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,13 @@ func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Containe
for i, s := range steps {
var argsForEntrypoint = []string{}
idx := strconv.Itoa(i)
switch i {
case 0:
argsForEntrypoint = []string{
// First step waits for the Downward volume file.
"-wait_file", filepath.Join(downwardMountPoint, downwardMountReadyFile),
"-wait_file_content", // Wait for file contents, not just an empty file.
// Start next step.
"-post_file", filepath.Join(runDir, idx, "out"),
"-termination_path", terminationPath,
"-step_metadata_dir", filepath.Join(runDir, idx, "status"),
"-cancel_file", filepath.Join(downwardMountPoint, downwardMountCancelFile),
}
default:
// All other steps wait for previous file, write next file.
argsForEntrypoint = []string{
"-wait_file", filepath.Join(runDir, strconv.Itoa(i-1), "out"),
"-post_file", filepath.Join(runDir, idx, "out"),
"-termination_path", terminationPath,
"-step_metadata_dir", filepath.Join(runDir, idx, "status"),
"-cancel_file", filepath.Join(downwardMountPoint, downwardMountCancelFile),
if i == 0 {
if waitForReadyAnnotation {
argsForEntrypoint = append(argsForEntrypoint,
// First step waits for the Downward volume file.
"-wait_file", filepath.Join(downwardMountPoint, downwardMountReadyFile),
"-wait_file_content", // Wait for file contents, not just an empty file.
)
}
} else { // Not the first step - wait for previous
argsForEntrypoint = append(argsForEntrypoint, "-wait_file", filepath.Join(runDir, strconv.Itoa(i-1), "out"))
Expand All @@ -156,6 +143,7 @@ func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Containe
"-post_file", filepath.Join(runDir, idx, "out"),
"-termination_path", terminationPath,
"-step_metadata_dir", filepath.Join(runDir, idx, "status"),
"-cancel_file", filepath.Join(downwardMountPoint, downwardMountCancelFile),
)
argsForEntrypoint = append(argsForEntrypoint, commonExtraEntrypointArgs...)
if taskSpec != nil {
Expand Down
19 changes: 10 additions & 9 deletions pkg/pod/entrypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestOrderContainersWithNoWait(t *testing.T) {
"-post_file", "/tekton/run/0/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/0/status",
"-cancel_file", "/tekton/downward/cancel",
"-entrypoint", "cmd", "--",
"arg1", "arg2",
},
Expand All @@ -138,6 +139,7 @@ func TestOrderContainersWithNoWait(t *testing.T) {
"-post_file", "/tekton/run/1/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/1/status",
"-cancel_file", "/tekton/downward/cancel",
"-entrypoint", "cmd1", "--",
"cmd2", "cmd3",
"arg1", "arg2",
Expand Down Expand Up @@ -390,6 +392,7 @@ func TestEntryPointOnError(t *testing.T) {
"-post_file", "/tekton/run/0/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/0/status",
"-cancel_file", "/tekton/downward/cancel",
"-on_error", "continue",
"-entrypoint", "cmd", "--",
},
Expand All @@ -404,6 +407,7 @@ func TestEntryPointOnError(t *testing.T) {
"-post_file", "/tekton/run/1/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/1/status",
"-cancel_file", "/tekton/downward/cancel",
"-on_error", "stopAndFail",
"-entrypoint", "cmd", "--",
},
Expand Down Expand Up @@ -482,10 +486,9 @@ func TestEntryPointStepOutputConfigs(t *testing.T) {
"-post_file", "/tekton/run/0/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/0/status",
"-cancel_file", "/tekton/downward/cancel",
"-stdout_path", "step-1-out",
"-cancel_file",
"/tekton/downward/cancel",
"-on_error", "continue",
// "-on_error", "continue",
"-entrypoint", "cmd", "--",
"arg1", "arg2",
},
Expand All @@ -499,10 +502,9 @@ func TestEntryPointStepOutputConfigs(t *testing.T) {
"-post_file", "/tekton/run/1/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/1/status",
"-cancel_file", "/tekton/downward/cancel",
"-stderr_path", "step-2-err",
"-cancel_file",
"/tekton/downward/cancel",
"-on_error", "stopAndFail",
// "-on_error", "stopAndFail",
"-entrypoint", "cmd1", "--",
"cmd2", "cmd3",
"arg1", "arg2",
Expand All @@ -517,11 +519,10 @@ func TestEntryPointStepOutputConfigs(t *testing.T) {
"-post_file", "/tekton/run/2/out",
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/run/2/status",
"-cancel_file", "/tekton/downward/cancel",
"-stdout_path", "step-3-out",
"-stderr_path", "step-3-err",
"-cancel_file",
"/tekton/downward/cancel",
"-on_error", "stopAndFail",
// "-on_error", "stopAndFail",
"-entrypoint", "cmd", "--",
"arg1", "arg2",
},
Expand Down
1 change: 1 addition & 0 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ _EOF_
"/tekton/termination",
"-step_metadata_dir",
"/tekton/run/0/status",
"-cancel_file", "/tekton/downward/cancel",
"-entrypoint",
"cmd",
"--",
Expand Down
26 changes: 12 additions & 14 deletions pkg/reconciler/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ import (
clock "k8s.io/utils/clock/testing"
"knative.dev/pkg/apis"
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
"knative.dev/pkg/changeset"
cminformer "knative.dev/pkg/configmap/informer"
"knative.dev/pkg/controller"
"knative.dev/pkg/kmeta"
"knative.dev/pkg/logging"
"knative.dev/pkg/ptr"

pkgreconciler "knative.dev/pkg/reconciler"
"knative.dev/pkg/system"

Expand Down Expand Up @@ -4601,7 +4599,7 @@ func TestReconcileOnCancelledTaskRunWithFeatureFlag(t *testing.T) {
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: "TaskRunCancelled",
Message: `TaskRun "test-taskrun-run-cancelled" was cancelled`,
Message: `TaskRun "test-taskrun-run-cancelled" was cancelled. `,
}

testCases := []struct {
Expand Down Expand Up @@ -4655,7 +4653,7 @@ func TestReconcileOnCancelledTaskRunWithFeatureFlag(t *testing.T) {

wantEvents := []string{
"Normal Started",
"Warning Failed TaskRun \"test-taskrun-run-cancelled\" was cancelled",
"Warning Failed TaskRun \"test-taskrun-run-cancelled\" was cancelled. ",
}
err = eventstest.CheckEventsOrdered(t, testAssets.Recorder.Events, "test-reconcile-on-cancelled-taskrun", wantEvents)
if !(err == nil) {
Expand Down Expand Up @@ -4794,12 +4792,12 @@ func TestCancelTaskRun(t *testing.T) {
},
}},
reason: v1beta1.TaskRunReasonCancelled,
message: "TaskRun test-taskrun-run-cancel was cancelled",
message: "TaskRun test-taskrun-run-cancel was cancelled. ",
expectedStatus: apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: v1beta1.TaskRunReasonCancelled.String(),
Message: "TaskRun test-taskrun-run-cancel was cancelled",
Message: "TaskRun test-taskrun-run-cancel was cancelled. ",
},
expectedStepStates: []v1beta1.StepState{
{
Expand Down Expand Up @@ -4859,12 +4857,12 @@ func TestCancelTaskRun(t *testing.T) {
},
}},
reason: v1beta1.TaskRunReasonCancelled,
message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled",
message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled. ",
expectedStatus: apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: v1beta1.TaskRunReasonCancelled.String(),
Message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled",
Message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled. ",
},
expectedStepStates: []v1beta1.StepState{
{
Expand Down Expand Up @@ -4940,12 +4938,12 @@ func TestCancelTaskRun(t *testing.T) {
},
}},
reason: v1beta1.TaskRunReasonCancelled,
message: "TaskRun test-taskrun-run-cancel-multiple-steps-waiting was cancelled",
message: "TaskRun test-taskrun-run-cancel-multiple-steps-waiting was cancelled. ",
expectedStatus: apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: v1beta1.TaskRunReasonCancelled.String(),
Message: "TaskRun test-taskrun-run-cancel-multiple-steps-waiting was cancelled",
Message: "TaskRun test-taskrun-run-cancel-multiple-steps-waiting was cancelled. ",
},
expectedStepStates: []v1beta1.StepState{
{
Expand Down Expand Up @@ -5016,12 +5014,12 @@ func TestCancelTaskRun(t *testing.T) {
},
}},
reason: v1beta1.TaskRunReasonCancelled,
message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled",
message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled. ",
expectedStatus: apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: v1beta1.TaskRunReasonCancelled.String(),
Message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled",
Message: "TaskRun test-taskrun-run-cancel-multiple-steps was cancelled. ",
},
expectedStepStates: []v1beta1.StepState{
{
Expand Down Expand Up @@ -5149,6 +5147,8 @@ func podArgs(cmd string, stdoutPath string, stderrPath string, additionalArgs []
"/tekton/termination",
"-step_metadata_dir",
fmt.Sprintf("/tekton/run/%d/status", idx),
"-cancel_file",
"/tekton/downward/cancel",
)
if stdoutPath != "" {
args = append(args, "-stdout_path", stdoutPath)
Expand All @@ -5157,8 +5157,6 @@ func podArgs(cmd string, stdoutPath string, stderrPath string, additionalArgs []
args = append(args, "-stderr_path", stderrPath)
}
args = append(args,
"-cancel_file",
"/tekton/downward/cancel",
"-entrypoint",
cmd,
"--",
Expand Down

0 comments on commit 96b82bc

Please sign in to comment.