Skip to content

Commit

Permalink
Add functional test for duplicate service
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi committed Jun 25, 2024
1 parent b7d60d1 commit 6ced53b
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/functional/dataplane/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func CreateDataplaneService(name types.NamespacedName, globalService bool) *unst
return th.CreateUnstructured(raw)
}

func CreateDataplaneServicesWithSameServiceType(name types.NamespacedName) {
CreateDataPlaneServiceFromSpec(name, map[string]interface{}{
"EDPMServiceType": "foo-service"})
CreateDataPlaneServiceFromSpec(types.NamespacedName{
Name: "duplicate-service", Namespace: name.Namespace}, map[string]interface{}{
"EDPMServiceType": "foo-service"})
}

// Create an OpenStackDataPlaneService with a given NamespacedName, and a given unstructured spec
func CreateDataPlaneServiceFromSpec(name types.NamespacedName, spec map[string]interface{}) *unstructured.Unstructured {
raw := map[string]interface{}{
Expand Down Expand Up @@ -149,6 +157,16 @@ func DefaultDataPlaneNodeSetSpec(nodeSetName string) map[string]interface{} {
}
}

func DuplicateServiceNodeSetSpec(nodeSetName string) map[string]interface{} {
spec := DefaultDataPlaneNodeSetSpec(nodeSetName)
spec["preProvisioned"] = true
spec["services"] = []string{
"foo-service",
"foo-service",
}
return spec
}

// Build OpenStackDataPlaneNodeSetSpec struct with empty `Nodes` list
func DefaultDataPlaneNoNodeSetSpec(tlsEnabled bool) map[string]interface{} {
spec := map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,87 @@ var _ = Describe("Dataplane Deployment Test", func() {
)
})
})
When("A dataplaneDeployment is created with duplicate service in nodeset", func() {
BeforeEach(func() {
CreateDataplaneServicesWithSameServiceType(dataplaneServiceName)
CreateSSHSecret(dataplaneSSHSecretName)
DeferCleanup(th.DeleteInstance, th.CreateSecret(neutronOvnMetadataSecretName, map[string][]byte{
"fake_keys": []byte("blih"),
}))
DeferCleanup(th.DeleteInstance, th.CreateSecret(novaNeutronMetadataSecretName, map[string][]byte{
"fake_keys": []byte("blih"),
}))
DeferCleanup(th.DeleteInstance, th.CreateSecret(novaCellComputeConfigSecretName, map[string][]byte{
"fake_keys": []byte("blih"),
}))
DeferCleanup(th.DeleteInstance, th.CreateSecret(novaMigrationSSHKey, map[string][]byte{
"ssh-privatekey": []byte("fake-ssh-private-key"),
"ssh-publickey": []byte("fake-ssh-public-key"),
}))
DeferCleanup(th.DeleteInstance, th.CreateSecret(ceilometerConfigSecretName, map[string][]byte{
"fake_keys": []byte("blih"),
}))
// DefaultDataPlanenodeSetSpec comes with two mock services, one marked for deployment on all nodesets
// But we will not create them to test this scenario
DeferCleanup(th.DeleteInstance, CreateNetConfig(dataplaneNetConfigName, DefaultNetConfigSpec()))
DeferCleanup(th.DeleteInstance, CreateDNSMasq(dnsMasqName, DefaultDNSMasqSpec()))
SimulateDNSMasqComplete(dnsMasqName)
DeferCleanup(th.DeleteInstance, CreateDataplaneNodeSet(dataplaneNodeSetName, DuplicateServiceNodeSetSpec(dataplaneNodeSetName.Name)))
DeferCleanup(th.DeleteInstance, CreateDataplaneDeployment(dataplaneDeploymentName, DefaultDataPlaneDeploymentSpec()))
SimulateIPSetComplete(dataplaneNodeName)
SimulateDNSDataComplete(dataplaneNodeSetName)
})
It("Should have Spec fields initialized", func() {
dataplaneDeploymentInstance := GetDataplaneDeployment(dataplaneDeploymentName)
expectedSpec := dataplanev1.OpenStackDataPlaneDeploymentSpec{
NodeSets: []string{"edpm-compute-nodeset"},
AnsibleTags: "",
AnsibleLimit: "",
AnsibleSkipTags: "",
BackoffLimit: &DefaultBackoffLimit,
DeploymentRequeueTime: 15,
ServicesOverride: nil,
}
Expect(dataplaneDeploymentInstance.Spec).Should(Equal(expectedSpec))
})

It("should have conditions set to true", func() {
// Create config map for OVN service
ovnConfigMapName := types.NamespacedName{
Namespace: namespace,
Name: "ovncontroller-config",
}
mapData := map[string]interface{}{
"ovsdb-config": "test-ovn-config",
}
th.CreateConfigMap(ovnConfigMapName, mapData)
service := GetService(dataplaneServiceName)
aeeName, _ := dataplaneutil.GetAnsibleExecutionNameAndLabels(service,
dataplaneDeploymentName.Name, dataplaneNodeSetName.Name)
Eventually(func(g Gomega) {
// Make an AnsibleEE name for each service
ansibleeeName := types.NamespacedName{
Name: aeeName,
Namespace: dataplaneDeploymentName.Namespace,
}
ansibleEE := GetAnsibleee(ansibleeeName)
ansibleEE.Status.JobStatus = ansibleeev1.JobStatusSucceeded
g.Expect(th.K8sClient.Status().Update(th.Ctx, ansibleEE)).To(Succeed())
})
th.ExpectCondition(
dataplaneDeploymentName,
ConditionGetterFunc(DataplaneDeploymentConditionGetter),
condition.ReadyCondition,
corev1.ConditionTrue,
)
th.ExpectCondition(
dataplaneDeploymentName,
ConditionGetterFunc(DataplaneDeploymentConditionGetter),
condition.InputReadyCondition,
corev1.ConditionFalse,
)
})
})

When("A dataplaneDeployment is created with non-existent service in nodeset", func() {
BeforeEach(func() {
Expand Down

0 comments on commit 6ced53b

Please sign in to comment.