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