diff --git a/test/e2e/testcase/testcase.go b/test/e2e/testcase/testcase.go index 6f260d44..a18103b2 100644 --- a/test/e2e/testcase/testcase.go +++ b/test/e2e/testcase/testcase.go @@ -6,6 +6,7 @@ import ( "github.com/onsi/ginkgo" "github.com/onsi/gomega" + "github.com/openkruise/kruise-game/apis/v1alpha1" gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1" "github.com/openkruise/kruise-game/pkg/util" "github.com/openkruise/kruise-game/test/e2e/client" @@ -115,6 +116,53 @@ func RunTestCases(f *framework.Framework) { gomega.Expect(err).To(gomega.BeNil()) }) + ginkgo.It("service qualities opsState", func() { + // Deploy + gss, err := f.DeployGssWithServiceQualities() + gomega.Expect(err).To(gomega.BeNil()) + err = f.ExpectGssCorrect(gss, []int{0, 1, 2}) + gomega.Expect(err).To(gomega.BeNil()) + + // Patch serviceQualities + patchFields := map[string]interface{}{ + "serviceQualities": []map[string]interface{}{ + { + "name": "health-check", + "containerName": "default-game", + "permanent": false, + "exec": map[string]interface{}{ + "command": []string{"sh", "-c", "exit 0"}, + }, + "serviceQualityAction": []map[string]interface{}{ + { + "state": true, + "opsState": "Maintaining", + }, + }, + }, + }, + } + + gss, err = f.PatchGssSpec(patchFields) + gomega.Expect(err).To(gomega.BeNil()) + + // Wait for OpsState propagation to all replicas + for i := 0; i < 3; i++ { + gsName := fmt.Sprintf("%s-%d", gss.GetName(), i) + err = f.WaitForGsSpecOpsState(gsName, "Maintaining") + gomega.Expect(err).To(gomega.BeNil(), fmt.Sprintf("GameServer %s should reach Maintaining state", gsName)) + } + + // Verify OpsState on all replicas + for i := 0; i < 3; i++ { + gsName := fmt.Sprintf("%s-%d", gss.GetName(), i) + gs, err := f.GetGameServer(gsName) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(gs.Spec.OpsState).To(gomega.Equal(v1alpha1.OpsState("Maintaining")), + fmt.Sprintf("GameServer %s should have opsState=Maintaining", gsName)) + } + }) + ginkgo.Describe("network control", func() { ginkgo.It("disables NodePort traffic when networkDisabled is true", func() { networkConf := []gameKruiseV1alpha1.NetworkConfParams{