Skip to content

Commit 4253c71

Browse files
Merge pull request #1336 from fmount/toporef
Add more topologyRef envTests
2 parents d50d76d + 2cf1987 commit 4253c71

File tree

2 files changed

+406
-0
lines changed

2 files changed

+406
-0
lines changed

tests/functional/ctlplane/base_test.go

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@ import (
2626
"k8s.io/apimachinery/pkg/types"
2727
"sigs.k8s.io/controller-runtime/pkg/client"
2828

29+
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
30+
glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1"
31+
heatv1 "github.com/openstack-k8s-operators/heat-operator/api/v1beta1"
32+
horizonv1 "github.com/openstack-k8s-operators/horizon-operator/api/v1beta1"
2933
infrav1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
3034
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
3135
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
36+
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
3237
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
38+
neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1"
3339
openstackclientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
3440
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
3541
dataplanev1 "github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1"
42+
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"
3643
)
3744

3845
type Names struct {
@@ -44,6 +51,11 @@ type Names struct {
4451
MemcachedCertName types.NamespacedName
4552
CinderName types.NamespacedName
4653
ManilaName types.NamespacedName
54+
GlanceName types.NamespacedName
55+
NeutronName types.NamespacedName
56+
HorizonName types.NamespacedName
57+
HeatName types.NamespacedName
58+
TelemetryName types.NamespacedName
4759
DBName types.NamespacedName
4860
DBCertName types.NamespacedName
4961
DBCell1Name types.NamespacedName
@@ -71,6 +83,7 @@ type Names struct {
7183
OVNDbServerNBName types.NamespacedName
7284
OVNDbServerSBName types.NamespacedName
7385
NeutronOVNCertName types.NamespacedName
86+
OpenStackTopology []types.NamespacedName
7487
}
7588

7689
func CreateNames(openstackControlplaneName types.NamespacedName) Names {
@@ -130,10 +143,30 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
130143
Namespace: openstackControlplaneName.Namespace,
131144
Name: "cinder",
132145
},
146+
GlanceName: types.NamespacedName{
147+
Namespace: openstackControlplaneName.Namespace,
148+
Name: "glance",
149+
},
133150
ManilaName: types.NamespacedName{
134151
Namespace: openstackControlplaneName.Namespace,
135152
Name: "manila",
136153
},
154+
NeutronName: types.NamespacedName{
155+
Namespace: openstackControlplaneName.Namespace,
156+
Name: "neutron",
157+
},
158+
HorizonName: types.NamespacedName{
159+
Namespace: openstackControlplaneName.Namespace,
160+
Name: "horizon",
161+
},
162+
HeatName: types.NamespacedName{
163+
Namespace: openstackControlplaneName.Namespace,
164+
Name: "heat",
165+
},
166+
TelemetryName: types.NamespacedName{
167+
Namespace: openstackControlplaneName.Namespace,
168+
Name: "telemetry",
169+
},
137170
DBName: types.NamespacedName{
138171
Namespace: openstackControlplaneName.Namespace,
139172
Name: "openstack",
@@ -198,6 +231,16 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
198231
Namespace: openstackControlplaneName.Namespace,
199232
Name: "cert-neutron-ovndbs",
200233
},
234+
OpenStackTopology: []types.NamespacedName{
235+
{
236+
Namespace: openstackControlplaneName.Namespace,
237+
Name: "openstack-topology",
238+
},
239+
{
240+
Namespace: openstackControlplaneName.Namespace,
241+
Name: "openstack-topology-alt",
242+
},
243+
},
201244
}
202245
}
203246

@@ -632,3 +675,95 @@ func SimulateControlplaneReady() {
632675

633676
}, timeout, interval).Should(Succeed())
634677
}
678+
679+
// GetSampleTopologySpec - A sample (and opinionated) Topology Spec
680+
func GetSampleTopologySpec() map[string]interface{} {
681+
// Build the topology Spec
682+
topologySpec := map[string]interface{}{
683+
"topologySpreadConstraints": []map[string]interface{}{
684+
{
685+
"maxSkew": 1,
686+
"topologyKey": k8s_corev1.LabelHostname,
687+
"whenUnsatisfiable": "ScheduleAnyway",
688+
},
689+
},
690+
}
691+
return topologySpec
692+
}
693+
694+
// CreateTopology - Creates a Topology CR based on the spec passed as input
695+
func CreateTopology(topology types.NamespacedName, spec map[string]interface{}) client.Object {
696+
raw := map[string]interface{}{
697+
"apiVersion": "topology.openstack.org/v1beta1",
698+
"kind": "Topology",
699+
"metadata": map[string]interface{}{
700+
"name": topology.Name,
701+
"namespace": topology.Namespace,
702+
},
703+
"spec": spec,
704+
}
705+
return th.CreateUnstructured(raw)
706+
}
707+
708+
// GetGlance
709+
func GetGlance(name types.NamespacedName) *glancev1.Glance {
710+
instance := &glancev1.Glance{}
711+
Eventually(func(g Gomega) {
712+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
713+
}, timeout, interval).Should(Succeed())
714+
return instance
715+
}
716+
717+
// GetCinder
718+
func GetCinder(name types.NamespacedName) *cinderv1.Cinder {
719+
instance := &cinderv1.Cinder{}
720+
Eventually(func(g Gomega) {
721+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
722+
}, timeout, interval).Should(Succeed())
723+
return instance
724+
}
725+
726+
// GetNeutron
727+
func GetNeutron(name types.NamespacedName) *neutronv1.NeutronAPI {
728+
instance := &neutronv1.NeutronAPI{}
729+
Eventually(func(g Gomega) {
730+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
731+
}, timeout, interval).Should(Succeed())
732+
return instance
733+
}
734+
735+
// GetManila
736+
func GetManila(name types.NamespacedName) *manilav1.Manila {
737+
instance := &manilav1.Manila{}
738+
Eventually(func(g Gomega) {
739+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
740+
}, timeout, interval).Should(Succeed())
741+
return instance
742+
}
743+
744+
// GetHorizon
745+
func GetHorizon(name types.NamespacedName) *horizonv1.Horizon {
746+
instance := &horizonv1.Horizon{}
747+
Eventually(func(g Gomega) {
748+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
749+
}, timeout, interval).Should(Succeed())
750+
return instance
751+
}
752+
753+
// GetHeat
754+
func GetHeat(name types.NamespacedName) *heatv1.Heat {
755+
instance := &heatv1.Heat{}
756+
Eventually(func(g Gomega) {
757+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
758+
}, timeout, interval).Should(Succeed())
759+
return instance
760+
}
761+
762+
// GetTelemetry
763+
func GetTelemetry(name types.NamespacedName) *telemetryv1.Telemetry {
764+
instance := &telemetryv1.Telemetry{}
765+
Eventually(func(g Gomega) {
766+
g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed())
767+
}, timeout, interval).Should(Succeed())
768+
return instance
769+
}

0 commit comments

Comments
 (0)