From 89eef0c53fdd2cfab361edcd4a85f2d856bf86d6 Mon Sep 17 00:00:00 2001 From: Kirill Sibirev Date: Fri, 8 Dec 2023 17:11:20 +0300 Subject: [PATCH] e2e test for 23.1 > 23.2 update I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en Add e2e to check that updating from 23.1 to 23.2 (and master_exit_read_only job) works. --- Pull Request resolved: https://github.com/ytsaurus/yt-k8s-operator/pull/68 --- .github/workflows/check.yaml | 2 + api/v1/test_helpers.go | 7 +- controllers/ytsaurus_controller_test.go | 135 +++++++++++++----------- 3 files changed, 78 insertions(+), 66 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index fbd91bfa..c23e1378 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -79,6 +79,8 @@ jobs: kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f docker pull ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de + docker pull ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d + kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d YTSAURUS_ENABLE_E2E_TESTS=true make test helm uninstall ytsaurus diff --git a/api/v1/test_helpers.go b/api/v1/test_helpers.go index f6876147..7373d1df 100644 --- a/api/v1/test_helpers.go +++ b/api/v1/test_helpers.go @@ -8,9 +8,10 @@ import ( ) const ( - YtsaurusName = "test-ytsaurus" - CoreImageFirst = "ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f" - CoreImageSecond = "ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de" + YtsaurusName = "test-ytsaurus" + CoreImageFirst = "ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f" + CoreImageSecond = "ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de" + CoreImageNextVer = "ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d" ) func CreateBaseYtsaurusResource(namespace string) *Ytsaurus { diff --git a/controllers/ytsaurus_controller_test.go b/controllers/ytsaurus_controller_test.go index 94b31a97..543a02d7 100644 --- a/controllers/ytsaurus_controller_test.go +++ b/controllers/ytsaurus_controller_test.go @@ -173,73 +173,20 @@ type testRow struct { var _ = Describe("Basic test for Ytsaurus controller", func() { Context("When setting up the test environment", func() { - It("Should run and update Ytsaurus", func() { - - By("Creating a Ytsaurus resource") - ctx := context.Background() - - namespace := "test1" - - ytsaurus := ytv1.CreateBaseYtsaurusResource(namespace) - - g := ytconfig.NewGenerator(ytsaurus, "local") - - defer deleteYtsaurus(ctx, ytsaurus) - runYtsaurus(ytsaurus) - - By("Creating ytsaurus client") - - ytClient := getYtClient(g, namespace) - - By("Check that cluster alive") - - res := make([]string, 0) - Expect(ytClient.ListNode(ctx, ypath.Path("/"), &res, nil)).Should(Succeed()) - - By("Check that tablet cell bundles are in `good` health") - - Eventually(func() bool { - notGoodBundles, err := components.GetNotGoodTabletCellBundles(ctx, ytClient) - if err != nil { - return false - } - return len(notGoodBundles) == 0 - }, timeout, interval).Should(BeTrue()) - - By("Run cluster update") - - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus)).Should(Succeed()) - ytsaurus.Spec.CoreImage = ytv1.CoreImageSecond - Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed()) - - Eventually(func() bool { - ytsaurus := &ytv1.Ytsaurus{} - err := k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus) - if err != nil { - return false - } - return ytsaurus.Status.State == ytv1.ClusterStateUpdating - }, timeout, interval).Should(BeTrue()) - - Eventually(func() bool { - ytsaurus := &ytv1.Ytsaurus{} - err := k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus) - if err != nil { - return false - } - return ytsaurus.Status.State == ytv1.ClusterStateRunning - }, timeout*5, interval).Should(BeTrue()) - - By("Check that cluster alive after update") - - Expect(ytClient.ListNode(ctx, ypath.Path("/"), &res, nil)).Should(Succeed()) - }) + It( + "Should run and update Ytsaurus within same major version", + getSimpleUpdateScenario("test1", ytv1.CoreImageSecond), + ) + It( + "Should run and update Ytsaurus to the next major version", + getSimpleUpdateScenario("test2", ytv1.CoreImageNextVer), + ) It("Should run and try to update Ytsaurus with tablet cell bundle which is not in `good` health", func() { By("Creating a Ytsaurus resource") ctx := context.Background() - namespace := "test2" + namespace := "test3" ytsaurus := ytv1.CreateBaseYtsaurusResource(namespace) @@ -288,7 +235,7 @@ var _ = Describe("Basic test for Ytsaurus controller", func() { By("Creating a Ytsaurus resource") ctx := context.Background() - namespace := "test3" + namespace := "test4" ytsaurus := ytv1.CreateBaseYtsaurusResource(namespace) ytsaurus.Spec.TabletNodes = make([]ytv1.TabletNodesSpec, 0) @@ -337,3 +284,65 @@ var _ = Describe("Basic test for Ytsaurus controller", func() { }) }) + +func getSimpleUpdateScenario(namespace, newImage string) func() { + return func() { + + By("Creating a Ytsaurus resource") + ctx := context.Background() + + ytsaurus := ytv1.CreateBaseYtsaurusResource(namespace) + + g := ytconfig.NewGenerator(ytsaurus, "local") + + defer deleteYtsaurus(ctx, ytsaurus) + runYtsaurus(ytsaurus) + + By("Creating ytsaurus client") + + ytClient := getYtClient(g, namespace) + + By("Check that cluster alive") + + res := make([]string, 0) + Expect(ytClient.ListNode(ctx, ypath.Path("/"), &res, nil)).Should(Succeed()) + + By("Check that tablet cell bundles are in `good` health") + + Eventually(func() bool { + notGoodBundles, err := components.GetNotGoodTabletCellBundles(ctx, ytClient) + if err != nil { + return false + } + return len(notGoodBundles) == 0 + }, timeout, interval).Should(BeTrue()) + + By("Run cluster update") + + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus)).Should(Succeed()) + ytsaurus.Spec.CoreImage = newImage + Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed()) + + Eventually(func() bool { + ytsaurus := &ytv1.Ytsaurus{} + err := k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus) + if err != nil { + return false + } + return ytsaurus.Status.State == ytv1.ClusterStateUpdating + }, timeout, interval).Should(BeTrue()) + + Eventually(func() bool { + ytsaurus := &ytv1.Ytsaurus{} + err := k8sClient.Get(ctx, types.NamespacedName{Name: ytv1.YtsaurusName, Namespace: namespace}, ytsaurus) + if err != nil { + return false + } + return ytsaurus.Status.State == ytv1.ClusterStateRunning + }, timeout*5, interval).Should(BeTrue()) + + By("Check that cluster alive after update") + + Expect(ytClient.ListNode(ctx, ypath.Path("/"), &res, nil)).Should(Succeed()) + } +}