|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package manager |
| 19 | + |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + |
| 23 | + netv1 "k8s.io/api/networking/v1" |
| 24 | + |
| 25 | + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" |
| 26 | + types "github.com/apache/apisix-ingress-controller/internal/types" |
| 27 | +) |
| 28 | + |
| 29 | +func TestV2ReadinessResources(t *testing.T) { |
| 30 | + resources := v2ReadinessResources() |
| 31 | + seen := make(map[string]bool, len(resources)) |
| 32 | + for _, resource := range resources { |
| 33 | + seen[types.GvkOf(resource).String()] = true |
| 34 | + } |
| 35 | + |
| 36 | + want := []string{ |
| 37 | + types.GvkOf(&netv1.Ingress{}).String(), |
| 38 | + types.GvkOf(&apiv2.ApisixRoute{}).String(), |
| 39 | + types.GvkOf(&apiv2.ApisixGlobalRule{}).String(), |
| 40 | + types.GvkOf(&apiv2.ApisixTls{}).String(), |
| 41 | + types.GvkOf(&apiv2.ApisixConsumer{}).String(), |
| 42 | + } |
| 43 | + for _, gvk := range want { |
| 44 | + if !seen[gvk] { |
| 45 | + t.Fatalf("expected readiness resources to include %s", gvk) |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + notExpected := []string{ |
| 50 | + types.GvkOf(&apiv2.ApisixPluginConfig{}).String(), |
| 51 | + types.GvkOf(&apiv2.ApisixUpstream{}).String(), |
| 52 | + } |
| 53 | + for _, gvk := range notExpected { |
| 54 | + if seen[gvk] { |
| 55 | + t.Fatalf("expected readiness resources to exclude %s", gvk) |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments