Skip to content

Commit

Permalink
integration test for sticky bit volume migration
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit-PX <[email protected]>
  • Loading branch information
Rohit-PX committed Apr 28, 2023
1 parent 2a02115 commit b5fac09
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/integration_test/migration_failover_failback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func testMigrationFailoverFailback(t *testing.T) {

t.Run("vanillaFailoverAndFailbackMigrationTest", vanillaFailoverAndFailbackMigrationTest)
t.Run("rancherFailoverAndFailbackMigrationTest", rancherFailoverAndFailbackMigrationTest)
t.Run("stickyFlagFailoverAndFailbackMigrationTest", stickyFlagFailoverAndFailbackMigrationTest)
}

func vanillaFailoverAndFailbackMigrationTest(t *testing.T) {
failoverAndFailbackMigrationTest(t)
failoverAndFailbackMigrationTest(t, "mysql-enc-pvc", "mysql-migration-failover-failback")
}

func rancherFailoverAndFailbackMigrationTest(t *testing.T) {
Expand Down Expand Up @@ -108,17 +109,19 @@ func rancherFailoverAndFailbackMigrationTest(t *testing.T) {
testMigrationFailback(t, preMigrationCtx, ctxs, scaleFactor, projectIDMappingsReverse, appKey, instanceID)
}

func failoverAndFailbackMigrationTest(t *testing.T) {
func stickyFlagFailoverAndFailbackMigrationTest(t *testing.T) {
failoverAndFailbackMigrationTest(t, "mysql-sticky", "mysql-migration-sticky")
}

func failoverAndFailbackMigrationTest(t *testing.T, appKey, migrationKey string) {

appKey := "mysql-enc-pvc"
instanceID := "mysql-migration-failover-failback"
// Migrate the resources
ctxs, preMigrationCtx := triggerMigration(
t,
instanceID,
migrationKey,
appKey,
nil,
[]string{instanceID},
[]string{migrationKey},
true,
false,
false,
Expand Down Expand Up @@ -150,9 +153,9 @@ func failoverAndFailbackMigrationTest(t *testing.T) {
// validate the migration summary based on the application specs that were deployed by the test
validateMigrationSummary(t, preMigrationCtx, expectedResources, expectedVolumes, migrationObj.Name, migrationObj.Namespace)

scaleFactor := testMigrationFailover(t, preMigrationCtx, ctxs, "", appKey, instanceID)
scaleFactor := testMigrationFailover(t, preMigrationCtx, ctxs, "", appKey, migrationKey)

testMigrationFailback(t, preMigrationCtx, ctxs, scaleFactor, "", appKey, instanceID)
testMigrationFailback(t, preMigrationCtx, ctxs, scaleFactor, "", appKey, migrationKey)
}

func testMigrationFailover(
Expand Down
14 changes: 14 additions & 0 deletions test/integration_test/specs/mysql-migration-sticky/migration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: stork.libopenstorage.org/v1alpha1
kind: Migration
metadata:
name: mysql-sticky-migration
spec:
# This should be the name of the cluster pair
clusterPair: remoteclusterpair
# If set to false this will migrate only the volumes. No PVCs, apps, etc will be migrated
includeResources: true
# If set to false, the deployments and stateful set replicas will be set to 0 on the destination. There will be an annotation with "stork.openstorage.org/migrationReplicas" to store the replica count from the source
startApplications: false
# List of namespaces to migrate
namespaces:
- mysql-sticky-mysql-migration-sticky
8 changes: 8 additions & 0 deletions test/integration_test/specs/mysql-sticky/aws/aws-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: mysql-sc
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Delete
7 changes: 7 additions & 0 deletions test/integration_test/specs/mysql-sticky/azure/azure-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: mysql-sc
provisioner: kubernetes.io/azure-disk
parameters:
skuName: Standard_LRS
10 changes: 10 additions & 0 deletions test/integration_test/specs/mysql-sticky/gce/gke-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: mysql-sc
parameters:
type: pd-standard
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true
10 changes: 10 additions & 0 deletions test/integration_test/specs/mysql-sticky/linstor/linstor-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: mysql-sc
provisioner: linstor.csi.linbit.com
allowVolumeExpansion: true
reclaimPolicy: Delete
parameters:
autoPlace: "2"
storagePool: sda
69 changes: 69 additions & 0 deletions test/integration_test/specs/mysql-sticky/mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
labels:
app: mysql
spec:
serviceName: mysql-service
replicas: 1
selector:
matchLabels:
app: mysql
version: "1"
template:
metadata:
labels:
app: mysql
version: "1"
spec:
schedulerName: stork
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
livenessProbe:
exec:
command: ["sh", "-c", "mysqladmin -u root -p$MYSQL_ROOT_PASSWORD ping"]
initialDelaySeconds: 70
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
exec:
command: ["sh", "-c", "mysql -u root -p$MYSQL_ROOT_PASSWORD -e \"select 1\""]
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: mysql-data
annotations:
volume.beta.kubernetes.io/storage-class: mysql-sticky-sc
px/secret-name: volume-secrets
px/secret-namespace: kube-system
px/secret-key: mysql-secret
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 8Gi
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
labels:
app: mysql
spec:
selector:
app: mysql
ports:
- name: transport
port: 3306
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: mysql-sticky-sc
provisioner: kubernetes.io/portworx-volume
parameters:
repl: "2"
sticky: "true"

0 comments on commit b5fac09

Please sign in to comment.