Skip to content

Commit

Permalink
adding service port update validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Sep 28, 2023
1 parent 4b69906 commit 73d99fd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/rack.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *SingleClusterReconciler) reconcileRacks() reconcileResult {
ignorablePodNames,
)

// handle failed racks
// Handle failed racks
for idx := range rackStateList {
var podList []*corev1.Pod

Expand Down
40 changes: 40 additions & 0 deletions test/cluster_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,46 @@ func rollingRestartClusterByRemovingNamespaceDynamicallyTest(
return updateCluster(k8sClient, ctx, aeroCluster)
}

func validateServiceUpdate(k8sClient client.Client, ctx goctx.Context,
clusterNamespacedName types.NamespacedName, port int32) error {
aeroCluster, err := getCluster(k8sClient, ctx, clusterNamespacedName)
if err != nil {
return err
}

serviceNamespacesNames := make([]types.NamespacedName, 0)
for podName := range aeroCluster.Status.Pods {
serviceNamespacesNames = append(serviceNamespacesNames,
types.NamespacedName{Name: podName, Namespace: clusterNamespacedName.Namespace})
}

serviceNamespacesNames = append(serviceNamespacesNames, clusterNamespacedName)

for _, serviceNamespacesName := range serviceNamespacesNames {
service := &corev1.Service{}

err = k8sClient.Get(ctx, serviceNamespacesName, service)
if err != nil {
return err
}

portChanged := false

for _, p := range service.Spec.Ports {
if p.Port == port {
portChanged = true
break
}
}

if !portChanged {
return fmt.Errorf("service %s port not configured correctly", serviceNamespacesName.Name)
}
}

return nil
}

func validateAerospikeConfigServiceClusterUpdate(
log logr.Logger, k8sClient client.Client, ctx goctx.Context,
clusterNamespacedName types.NamespacedName, updatedKeys []string,
Expand Down
6 changes: 6 additions & 0 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,19 @@ func UpdateClusterTest(ctx goctx.Context) {
)
Expect(err).ToNot(HaveOccurred())

err = validateServiceUpdate(k8sClient, ctx, clusterNamespacedName, tlsPort)
Expect(err).ToNot(HaveOccurred())

By("RollingRestart By changing tls to non-tls")

err = rollingRestartClusterByDisablingTLS(
k8sClient, ctx, clusterNamespacedName,
)
Expect(err).ToNot(HaveOccurred())

err = validateServiceUpdate(k8sClient, ctx, clusterNamespacedName, nontlsPort)
Expect(err).ToNot(HaveOccurred())

By("Upgrade/Downgrade")

// TODO: How to check if it is checking cluster stability before killing node
Expand Down
7 changes: 5 additions & 2 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const aerospikeNs string = "aerospike"
const zoneKey = "topology.kubernetes.io/zone"
const regionKey = "topology.kubernetes.io/region"

const tlsPort = 4333
const nontlsPort = 3000

// list of all the namespaces used in test-suite
var testNamespaces = []string{namespace, multiClusterNs1, multiClusterNs2, aerospikeNs}

Expand Down Expand Up @@ -408,8 +411,8 @@ func getNetworkTLSConfig() map[string]interface{} {
return map[string]interface{}{
"service": map[string]interface{}{
"tls-name": "aerospike-a-0.test-runner",
"tls-port": 4333,
"port": 3000,
"tls-port": tlsPort,
"port": nontlsPort,
},
"fabric": map[string]interface{}{
"tls-name": "aerospike-a-0.test-runner",
Expand Down

0 comments on commit 73d99fd

Please sign in to comment.