|
| 1 | +/* |
| 2 | +Copyright 2023. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +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 | + |
| 17 | +package functional_test |
| 18 | + |
| 19 | +import ( |
| 20 | + . "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports |
| 21 | + . "github.com/onsi/gomega" //revive:disable:dot-imports |
| 22 | + |
| 23 | + testv1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1" |
| 24 | + corev1 "k8s.io/api/core/v1" |
| 25 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 26 | + "k8s.io/apimachinery/pkg/types" |
| 27 | +) |
| 28 | + |
| 29 | +var _ = Describe("TempestController", func() { |
| 30 | + When("Tempest CR is created", func() { |
| 31 | + var tempestName types.NamespacedName |
| 32 | + |
| 33 | + BeforeEach(func() { |
| 34 | + // Create OpenStack config ConfigMap |
| 35 | + openstackConfigMap := &corev1.ConfigMap{ |
| 36 | + ObjectMeta: metav1.ObjectMeta{ |
| 37 | + Name: "openstack-config", |
| 38 | + Namespace: namespace, |
| 39 | + }, |
| 40 | + Data: map[string]string{ |
| 41 | + "clouds.yaml": "clouds:\n default:\n auth:\n auth_url: http://keystone:5000", |
| 42 | + }, |
| 43 | + } |
| 44 | + Expect(k8sClient.Create(ctx, openstackConfigMap)).Should(Succeed()) |
| 45 | + |
| 46 | + // Create OpenStack config Secret |
| 47 | + openstackSecret := &corev1.Secret{ |
| 48 | + ObjectMeta: metav1.ObjectMeta{ |
| 49 | + Name: "openstack-config-secret", |
| 50 | + Namespace: namespace, |
| 51 | + }, |
| 52 | + StringData: map[string]string{ |
| 53 | + "secure.yaml": "clouds:\n default:\n auth:\n password: secret", |
| 54 | + }, |
| 55 | + } |
| 56 | + Expect(k8sClient.Create(ctx, openstackSecret)).Should(Succeed()) |
| 57 | + |
| 58 | + // Create a basic Tempest CR |
| 59 | + tempestName = types.NamespacedName{ |
| 60 | + Name: "tempest-tests", |
| 61 | + Namespace: namespace, |
| 62 | + } |
| 63 | + |
| 64 | + tempest := &testv1.Tempest{ |
| 65 | + ObjectMeta: metav1.ObjectMeta{ |
| 66 | + Name: tempestName.Name, |
| 67 | + Namespace: tempestName.Namespace, |
| 68 | + }, |
| 69 | + Spec: testv1.TempestSpec{ |
| 70 | + CommonOptions: testv1.CommonOptions{ |
| 71 | + StorageClass: "local-storage", |
| 72 | + }, |
| 73 | + CommonOpenstackConfig: testv1.CommonOpenstackConfig{ |
| 74 | + OpenStackConfigMap: "openstack-config", |
| 75 | + OpenStackConfigSecret: "openstack-config-secret", |
| 76 | + }, |
| 77 | + TempestRun: testv1.TempestRunSpec{ |
| 78 | + IncludeList: "tempest.api.identity.v3", |
| 79 | + }, |
| 80 | + }, |
| 81 | + } |
| 82 | + Expect(k8sClient.Create(ctx, tempest)).Should(Succeed()) |
| 83 | + }) |
| 84 | + |
| 85 | + It("should have a finalizer", func() { |
| 86 | + // the reconciler loop adds the finalizer so we have to wait for |
| 87 | + // it to run |
| 88 | + Eventually(func() []string { |
| 89 | + return GetTempest(tempestName).Finalizers |
| 90 | + }, timeout, interval).Should(ContainElement("openstack.org/tempest")) |
| 91 | + }) |
| 92 | + }) |
| 93 | +}) |
0 commit comments