Skip to content

Commit

Permalink
fix: Some CRDs missing status sub-resource (#1809)
Browse files Browse the repository at this point in the history
* fix: Apisix Cluster Config status

---------

Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Co-authored-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
  • Loading branch information
Chever-John and Revolyssup committed Dec 13, 2023
1 parent 8fbf558 commit 1da1ca0
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-ci-v2-cron-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-test-ci-v2-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions samples/deploy/crd/v1/ApisixClusterConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 26 additions & 1 deletion samples/deploy/crd/v1/ApisixConsumer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion test/e2e/scaffold/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
42 changes: 42 additions & 0 deletions test/e2e/suite-cluster/status.go
Original file line number Diff line number Diff line change
@@ -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")
})
})
19 changes: 15 additions & 4 deletions test/e2e/suite-ingress/suite-ingress-features/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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() {
Expand Down

0 comments on commit 1da1ca0

Please sign in to comment.