Skip to content

Commit

Permalink
e2e test for 23.1 > 23.2 update
Browse files Browse the repository at this point in the history
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: #68
  • Loading branch information
l0kix2 authored and robot-piglet committed Dec 8, 2023
1 parent 2ef4b77 commit 89eef0c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions api/v1/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
135 changes: 72 additions & 63 deletions controllers/ytsaurus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
}
}

0 comments on commit 89eef0c

Please sign in to comment.