patch containerd-test-2.0.0.
After transitioning lakitu-next presubmit job to rbe, the tests TestContainerStopCancellation and TestContainerPids (part of integration_containerd) are failing.
The same errors happened on Lakitu QA migration to rbe and were fixed with a patches for containerd-tes 1.7. Same fixes should be applied to version 2.0 which lakitu-next uses.
Full error in the bug description.
BUG=b/337081919
TEST=lakitu_next presubmit
Change-Id: Ib0ba9c15961c79d1556f66b20de79abdc077d06d
Reviewed-on: https://cos-review.googlesource.com/c/cos/overlays/board-overlays/+/70550
Tested-by: RBE-prod-presubmit <service-269995278450@remotebuildexecution.iam.gserviceaccount.com>
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
diff --git a/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0-r1.ebuild b/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0-r2.ebuild
similarity index 100%
rename from project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0-r1.ebuild
rename to project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0-r2.ebuild
diff --git a/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0.ebuild b/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0.ebuild
index 218e414..a5619bf 100644
--- a/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0.ebuild
+++ b/project-lakitu/app-containers/containerd-test/containerd-test-2.0.0_beta0.ebuild
@@ -45,6 +45,8 @@
PATCHES=(
"${FILESDIR}"/1.7.0-Add-cgroup-parent-to-PodSandboxConfig.patch
+ "${FILESDIR}"/2.0.0-fix_TestContainerStopCancellation.patch
+ "${FILESDIR}"/2.0.0-fix_TestContainerPids.patch
)
src_unpack() {
diff --git a/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerPids.patch b/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerPids.patch
new file mode 100644
index 0000000..745e880
--- /dev/null
+++ b/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerPids.patch
@@ -0,0 +1,20 @@
+From: Miri Amarilio <mirilio@google.com>
+Date: Thu, 15 Feb 2024 15:27:00 +0000
+Subject: [PATCH] Add sleep time in TestContainerPids after creating the new task to let the task fully start (and start the inf sleep process inside the container).
+
+In some cases the test will fail with the error of finding only 1 pid when expecting 2. This means that the sleep process did not exist yet when querying for container pids.
+The resolution is to wait after creating the sleep process and before querying for pids.
+
+diff --git a/integration/client/container_test.go b/integration/client/container_test.go
+index ba41e04..fb5e7c7 100644
+--- a/integration/client/container_test.go
++++ b/integration/client/container_test.go
+@@ -565,6 +565,8 @@ func TestContainerPids(t *testing.T) {
+ if err := task.Start(ctx); err != nil {
+ t.Fatal(err)
+ }
++ // Sleep to let the task fully start (the task starts an infinite sleep in the container in order to add another process)
++ time.Sleep(5 * time.Second)
+
+ taskPid := task.Pid()
+ if taskPid < 1 {
diff --git a/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerStopCancellation.patch b/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerStopCancellation.patch
new file mode 100644
index 0000000..4d02540
--- /dev/null
+++ b/project-lakitu/app-containers/containerd-test/files/2.0.0-fix_TestContainerStopCancellation.patch
@@ -0,0 +1,20 @@
+From: Miri Amarilio <mirilio@google.com>
+Date: Wed, 14 Feb 2024 15:45:00 +0000
+Subject: [PATCH] Add sleep time in TestContainerStopCancellation to let the container completely start up before continuing.
+
+In some cases this test would fail due to the container not being fully up by the time the next command in the test is executed.
+This patch is meant to prevent that from happening.
+
+diff --git a/integration/container_stop_test.go b/integration/container_stop_test.go
+index 616a940..ef4eb0f 100644
+--- a/integration/container_stop_test.go
++++ b/integration/container_stop_test.go
+@@ -97,6 +97,8 @@ func TestContainerStopCancellation(t *testing.T) {
+
+ t.Log("Start the container")
+ require.NoError(t, runtimeService.StartContainer(cn))
++ // Allow the container to fully start before continuing
++ time.Sleep(5 * time.Second)
+
+ t.Log("Stop the container with 3s timeout, but 1s context timeout")
+ // Note that with container pid namespace, the sleep process