Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
l0kix2 committed Apr 17, 2024
1 parent 0637d74 commit f13a341
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions test/e2e/ytsaurus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,85 @@ var _ = Describe("Basic test for Ytsaurus controller", func() {
"Should run and update Ytsaurus to the next major version",
getSimpleUpdateScenario("test-major-update", ytv1.CoreImageNextVer),
)
It(
"Should be updated according to UpdateStrategy",
func(ctx context.Context) {
namespace := "teststrategy"

By("Creating a Ytsaurus resource")
ytsaurus := ytv1.CreateBaseYtsaurusResource(namespace)
DeferCleanup(deleteYtsaurus, ytsaurus)
name := types.NamespacedName{Name: ytsaurus.GetName(), Namespace: namespace}
deployAndCheck(ytsaurus, namespace)

By("Run cluster update with strategy blocked")
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
ytsaurus.Spec.UpdateStrategy = ytv1.UpdateStrategyBlocked
// Discovery count triggers change in all yson configs.
ytsaurus.Spec.Discovery.InstanceCount += 1
updateAndCheck(ytsaurus, namespace)
//Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

Check failure on line 281 in test/e2e/ytsaurus_controller_test.go

View workflow job for this annotation

GitHub Actions / Run checks

commentFormatting: put a space between `//` and comment text (gocritic)

By("Sleep 5 second and check not updated")
time.Sleep(5 * time.Second)
ytsaurus = &ytv1.Ytsaurus{}
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
Expect(ytsaurus.Status.State).Should(Equal(ytv1.ClusterStateRunning))
// TODO: check pods

By("Run cluster update with strategy stateless only")
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
ytsaurus.Spec.UpdateStrategy = ytv1.UpdateStrategyStatelessOnly
ytsaurus.Spec.Discovery.InstanceCount += 1
//Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

Check failure on line 294 in test/e2e/ytsaurus_controller_test.go

View workflow job for this annotation

GitHub Actions / Run checks

commentFormatting: put a space between `//` and comment text (gocritic)
updateAndCheck(ytsaurus, namespace)
// UPDATINGCOMPONENTS=["Discovery","DataNode","HttpProxy","ExecNode","Scheduler","ControllerAgent"]
EventuallyYtsaurus(ctx, name, reactionTimeout).Should(HaveClusterState(ytv1.ClusterStateUpdating))

By("Wait cluster update with stateless strategy complete")
EventuallyYtsaurus(ctx, name, upgradeTimeout).Should(HaveClusterState(ytv1.ClusterStateRunning))
// TODO: check discovery pods timestamps

By("Run cluster update with strategy tablet nodes only")
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
ytsaurus.Spec.UpdateStrategy = ytv1.UpdateStrategyTabletNodesOnly
ytsaurus.Spec.Discovery.InstanceCount += 1
//Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

Check failure on line 307 in test/e2e/ytsaurus_controller_test.go

View workflow job for this annotation

GitHub Actions / Run checks

commentFormatting: put a space between `//` and comment text (gocritic)
updateAndCheck(ytsaurus, namespace)
EventuallyYtsaurus(ctx, name, reactionTimeout).Should(HaveClusterState(ytv1.ClusterStateUpdating))

By("Wait cluster update with tablet nodes strategy complete")
EventuallyYtsaurus(ctx, name, upgradeTimeout).Should(HaveClusterState(ytv1.ClusterStateRunning))
// TODO: check tnds pods timestamps
// UPDATINGCOMPONENTS
// teststrategy ytsaurus.cluster.ytsaurus.tech/test-ytsaurus Updating WaitingForTabletCellsRemoved ["TabletNode"]

By("Run cluster update with strategy master only")
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
ytsaurus.Spec.UpdateStrategy = ytv1.UpdateStrategyMasterOnly
ytsaurus.Spec.Discovery.InstanceCount += 1
//Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

Check failure on line 321 in test/e2e/ytsaurus_controller_test.go

View workflow job for this annotation

GitHub Actions / Run checks

commentFormatting: put a space between `//` and comment text (gocritic)
updateAndCheck(ytsaurus, namespace)
EventuallyYtsaurus(ctx, name, reactionTimeout).Should(HaveClusterState(ytv1.ClusterStateUpdating))

By("Wait cluster update with master only complete")
EventuallyYtsaurus(ctx, name, upgradeTimeout).Should(HaveClusterState(ytv1.ClusterStateRunning))
// TODO: check master pods timestamps

// TODO: strategy full update
By("Run cluster update with strategy full")
Expect(k8sClient.Get(ctx, name, ytsaurus)).Should(Succeed())
ytsaurus.Spec.UpdateStrategy = ytv1.UpdateStrategyFull
ytsaurus.Spec.Discovery.InstanceCount += 1
//Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

Check failure on line 334 in test/e2e/ytsaurus_controller_test.go

View workflow job for this annotation

GitHub Actions / Run checks

commentFormatting: put a space between `//` and comment text (gocritic)
updateAndCheck(ytsaurus, namespace)
EventuallyYtsaurus(ctx, name, reactionTimeout).Should(HaveClusterState(ytv1.ClusterStateUpdating))

By("Wait cluster update with full update complete")
EventuallyYtsaurus(ctx, name, upgradeTimeout).Should(HaveClusterState(ytv1.ClusterStateRunning))
// check all created recently (or after smth)
},
)

// This is a test for specific regression bug when master pods are recreated during PossibilityCheck stage.
It("Master shouldn't be recreated before WaitingForPodsCreation state if config changes", func(ctx context.Context) {
Expand Down Expand Up @@ -630,6 +709,15 @@ func deployAndCheck(ytsaurus *ytv1.Ytsaurus, namespace string) {
checkClusterViability(ytClient)
}

func updateAndCheck(ytsaurus *ytv1.Ytsaurus, namespace string) {
g := ytconfig.NewGenerator(ytsaurus, "local")
Expect(k8sClient.Update(ctx, ytsaurus)).Should(Succeed())

By("Creating ytsaurus client")
ytClient := getYtClient(g, namespace)
checkClusterBaseViability(ytClient)
}

func getSimpleUpdateScenario(namespace, newImage string) func(ctx context.Context) {
return func(ctx context.Context) {
By("Creating a Ytsaurus resource")
Expand Down

0 comments on commit f13a341

Please sign in to comment.