This is an automated email from the ASF dual-hosted git repository.

ashishtiwari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 1da1ca0c fix: Some CRDs missing status sub-resource (#1809)
1da1ca0c is described below

commit 1da1ca0c60cc726bb9dfe489678bfe7096808cd2
Author: Chever John <[email protected]>
AuthorDate: Wed Dec 13 13:53:54 2023 +0800

    fix: Some CRDs missing status sub-resource (#1809)
    
    * fix: Apisix Cluster Config status
    
    ---------
    
    Signed-off-by: Ashish Tiwari <[email protected]>
    Co-authored-by: Ashish Tiwari <[email protected]>
---
 .github/workflows/e2e-test-ci-v2-cron-dev.yml      |  2 +-
 .github/workflows/e2e-test-ci-v2-cron.yml          |  1 +
 samples/deploy/crd/v1/ApisixClusterConfig.yaml     | 24 +++++++++++++
 samples/deploy/crd/v1/ApisixConsumer.yaml          | 27 +++++++++++++-
 test/e2e/scaffold/cluster_config.go                |  5 ++-
 test/e2e/suite-cluster/status.go                   | 42 ++++++++++++++++++++++
 .../suite-ingress/suite-ingress-features/status.go | 19 +++++++---
 7 files changed, 113 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/e2e-test-ci-v2-cron-dev.yml 
b/.github/workflows/e2e-test-ci-v2-cron-dev.yml
index 1def17ac..19e65731 100644
--- a/.github/workflows/e2e-test-ci-v2-cron-dev.yml
+++ b/.github/workflows/e2e-test-ci-v2-cron-dev.yml
@@ -33,6 +33,7 @@ concurrency:
 
 jobs:
   changes:
+    if: ${{ (!github.event.pull_request.draft && github.event.schedule == '0 0 
* * *') }}
     runs-on: ubuntu-20.04
     outputs:
       docs: ${{ steps.filter.outputs.docs }}
@@ -205,7 +206,6 @@ jobs:
         env:
           E2E_FOCUS: "${{ matrix.suite }}"
           ENABLE_PROXY: "false"
-          INGRESS_CLASS: "${{ matrix.ingress-class-values }}"
           E2E_SKIP_BUILD: "1"
           E2E_FLAKE_ATTEMPTS: "2"
           E2E_ENV: "ci"
diff --git a/.github/workflows/e2e-test-ci-v2-cron.yml 
b/.github/workflows/e2e-test-ci-v2-cron.yml
index 230bdd66..c765f6d5 100644
--- a/.github/workflows/e2e-test-ci-v2-cron.yml
+++ b/.github/workflows/e2e-test-ci-v2-cron.yml
@@ -198,4 +198,5 @@ jobs:
           E2E_FLAKE_ATTEMPTS: "2"
           E2E_ENV: "ci"
         run: |
+          echo ${E2E_FOCUS} | grep "suite-cluster" && export E2E_NODES=1
           make e2e-test
diff --git a/samples/deploy/crd/v1/ApisixClusterConfig.yaml 
b/samples/deploy/crd/v1/ApisixClusterConfig.yaml
index 355883e7..5b703260 100644
--- a/samples/deploy/crd/v1/ApisixClusterConfig.yaml
+++ b/samples/deploy/crd/v1/ApisixClusterConfig.yaml
@@ -73,3 +73,27 @@ spec:
                           type: number
                           minimum: 0.00001
                           maximum: 1
+            status:
+              type: object
+              properties:
+                observedGeneration:
+                  type: integer
+                conditions:
+                  type: array
+                  items:
+                    type: object
+                    properties:
+                      type:
+                        type: string
+                      status:
+                        type: string
+                      lastTransitionTime:
+                        type: string
+                      reason:
+                        type: string
+                      message:
+                        type: string
+                  required:
+                    - type
+                    - status
+                    - lastTransitionTime
diff --git a/samples/deploy/crd/v1/ApisixConsumer.yaml 
b/samples/deploy/crd/v1/ApisixConsumer.yaml
index 1bcdd0a3..6ccc5897 100644
--- a/samples/deploy/crd/v1/ApisixConsumer.yaml
+++ b/samples/deploy/crd/v1/ApisixConsumer.yaml
@@ -224,4 +224,29 @@ spec:
                             name:
                               type: string
                               minLength: 1
-                          required: null
+                          required:
+                            - name
+            status:
+              type: object
+              properties:
+                observedGeneration:
+                  type: integer
+                conditions:
+                  type: array
+                  items:
+                    type: object
+                    properties:
+                      type:
+                        type: string
+                      status:
+                        type: string
+                      lastTransitionTime:
+                        type: string
+                      reason:
+                        type: string
+                      message:
+                        type: string
+                  required:
+                    - type
+                    - status
+                    - lastTransitionTime
diff --git a/test/e2e/scaffold/cluster_config.go 
b/test/e2e/scaffold/cluster_config.go
index 4a1b4a88..6f5e78f0 100644
--- a/test/e2e/scaffold/cluster_config.go
+++ b/test/e2e/scaffold/cluster_config.go
@@ -53,7 +53,10 @@ func (s *Scaffold) NewApisixClusterConfig(name string, 
enable bool, enablePrefer
        if err := s.CreateResourceFromString(cc); err != nil {
                return err
        }
-       time.Sleep(5 * time.Second)
+       s.addFinalizers(func() {
+               _ = s.DeleteResourceFromString(cc)
+       })
+
        return nil
 }
 
diff --git a/test/e2e/suite-cluster/status.go b/test/e2e/suite-cluster/status.go
new file mode 100644
index 00000000..0aac5b74
--- /dev/null
+++ b/test/e2e/suite-cluster/status.go
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package cluster
+
+import (
+       "time"
+
+       "github.com/onsi/ginkgo/v2"
+       "github.com/stretchr/testify/assert"
+
+       "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-cluster: CRDs status subresource Testing", 
func() {
+       s := scaffold.NewDefaultScaffold()
+
+       ginkgo.It("check ApisixClusterConfig status is recorded", func() {
+               // create ApisixClusterConfig resource
+               assert.Nil(ginkgo.GinkgoT(), 
s.NewApisixClusterConfig("default", true, true), "create cluster config error")
+               time.Sleep(6 * time.Second)
+
+               // status should be recorded as successful
+               output, err := s.GetOutputFromString("acc", "default", "-o", 
"yaml")
+               assert.Nil(ginkgo.GinkgoT(), err, "Get output of 
ApisixClusterConfig resource")
+               assert.Contains(ginkgo.GinkgoT(), output, "type: 
ResourcesAvailable", "status.conditions.type is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, "reason: 
ResourcesSynced", "status.conditions.reason  is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, `status: "True"`, 
"status.conditions.status  is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, "message: Sync 
Successfully", "status.conditions.message  is recorded")
+       })
+})
diff --git a/test/e2e/suite-ingress/suite-ingress-features/status.go 
b/test/e2e/suite-ingress/suite-ingress-features/status.go
index 5c9513f2..a51fa5ab 100644
--- a/test/e2e/suite-ingress/suite-ingress-features/status.go
+++ b/test/e2e/suite-ingress/suite-ingress-features/status.go
@@ -123,7 +123,7 @@ spec:
 `
                assert.Nil(ginkgo.GinkgoT(), 
s.CreateVersionedApisixResource(apc))
                time.Sleep(6 * time.Second)
-               // status should be recorded as successfulen
+               // status should be recorded as successful
                output, err := s.GetOutputFromString("apc", "test-apc", "-o", 
"yaml")
                assert.Nil(ginkgo.GinkgoT(), err, "Get output of 
ApisixPluginConfig resource")
                assert.Contains(ginkgo.GinkgoT(), output, "type: 
ResourcesAvailable", "status.conditions.type is recorded")
@@ -213,7 +213,7 @@ wrw7im4TNSAdwVX4Y1F4svJ2as5SJn5QYGAzXDixNuwzXYrpP9rzA2s=
                host := "api6.com"
                assert.Nil(ginkgo.GinkgoT(), s.NewApisixTls(tlsName, host, 
secretName), "create tls error")
                time.Sleep(6 * time.Second)
-               // status should be recorded as successfulen
+               // status should be recorded as successful
                output, err := s.GetOutputFromString("atls", tlsName, "-o", 
"yaml")
                assert.Nil(ginkgo.GinkgoT(), err, "Get output of 
ApisixPluginConfig resource")
                assert.Contains(ginkgo.GinkgoT(), output, "type: 
ResourcesAvailable", "status.conditions.type is recorded")
@@ -233,8 +233,19 @@ wrw7im4TNSAdwVX4Y1F4svJ2as5SJn5QYGAzXDixNuwzXYrpP9rzA2s=
        })
 
        //TODO: ApisixGlobal
-       //TODO: ApisixConsumer  CRD missing status definition
-       //TODO: ApisixClusterConfig CRD missing status definition
+       ginkgo.It("check ApisixConsumer status is recorded", func() {
+               // create ApisixConsumer resource
+               assert.Nil(ginkgo.GinkgoT(), 
s.ApisixConsumerBasicAuthCreated("test-apisix-consumer", "foo", "bar"), "create 
consumer error")
+               time.Sleep(6 * time.Second)
+
+               // status should be recorded as successful
+               output, err := s.GetOutputFromString("ac", 
"test-apisix-consumer", "-o", "yaml")
+               assert.Nil(ginkgo.GinkgoT(), err, "Get output of ApisixConsumer 
resource")
+               assert.Contains(ginkgo.GinkgoT(), output, "type: 
ResourcesAvailable", "status.conditions.type is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, "reason: 
ResourcesSynced", "status.conditions.reason  is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, `status: "True"`, 
"status.conditions.status  is recorded")
+               assert.Contains(ginkgo.GinkgoT(), output, "message: Sync 
Successfully", "status.conditions.message  is recorded")
+       })
 })
 
 var _ = ginkgo.Describe("suite-ingress-features: Ingress LB Status Testing", 
func() {

Reply via email to