From 47664085b9699808b29d428c5140bda43fa5c31f Mon Sep 17 00:00:00 2001 From: Masayuki Ishii Date: Fri, 2 Jun 2023 09:00:52 +0000 Subject: [PATCH] Add test to check that MySQL pod can become guarranteed QoS Signed-off-by: Masayuki Ishii --- e2e/lifecycle_test.go | 17 +++++++++++++++++ e2e/testdata/single.yaml | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/e2e/lifecycle_test.go b/e2e/lifecycle_test.go index 7ba671c83..aa21cfc31 100644 --- a/e2e/lifecycle_test.go +++ b/e2e/lifecycle_test.go @@ -45,6 +45,23 @@ var _ = Context("lifecycle", func() { }).Should(Succeed()) }) + It("should give a pod the guarranteed QoS class", func() { + Eventually(func() error { + out, err := kubectl(nil, "get", "-n", "foo", "pod", "moco-single-0", "-o", "json") + if err != nil { + return err + } + pod := &corev1.Pod{} + if err := json.Unmarshal(out, pod); err != nil { + return err + } + if pod.Status.QOSClass != corev1.PodQOSGuaranteed { + return fmt.Errorf("mysql pod is not the Guarranteed QoS class: %s", pod.Status.QOSClass) + } + return nil + }).Should(Succeed()) + }) + It("should log slow queries via sidecar", func() { out := kubectlSafe(nil, "moco", "-n", "foo", "mysql", "single", "--", "-N", "-e", "SELECT @@long_query_time") val, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64) diff --git a/e2e/testdata/single.yaml b/e2e/testdata/single.yaml index c31d8de18..4b05ff142 100644 --- a/e2e/testdata/single.yaml +++ b/e2e/testdata/single.yaml @@ -24,6 +24,10 @@ spec: containers: - name: mysqld image: quay.io/cybozu/mysql:{{ . }} + resources: + limits: + cpu: "0.5" + memory: 1Gi volumeClaimTemplates: - metadata: name: mysql-data