(namespace, clusterName string, timeout int)
| 184 | } |
| 185 | |
| 186 | func OfflineResizePVC(namespace, clusterName string, timeout int) { |
| 187 | walStorageEnabled, err := storage.IsWalStorageEnabled( |
| 188 | env.Ctx, env.Client, |
| 189 | namespace, clusterName, |
| 190 | ) |
| 191 | Expect(err).ToNot(HaveOccurred()) |
| 192 | |
| 193 | By("verify PVC size before expansion", func() { |
| 194 | // Gathering PVC list for future use of comparison and deletion after storage expansion |
| 195 | pvc := &corev1.PersistentVolumeClaimList{} |
| 196 | err := env.Client.List(env.Ctx, pvc, ctrlclient.InNamespace(namespace)) |
| 197 | Expect(err).ToNot(HaveOccurred()) |
| 198 | // Iterating through PVC list to verify the default size for future comparison |
| 199 | for _, pvClaim := range pvc.Items { |
| 200 | Expect(pvClaim.Status.Capacity.Storage().String()).To(BeEquivalentTo("1Gi")) |
| 201 | } |
| 202 | }) |
| 203 | By("expanding Cluster storage", func() { |
| 204 | // Expanding cluster storage |
| 205 | storageType := []string{"storage"} |
| 206 | if walStorageEnabled { |
| 207 | storageType = append(storageType, "walStorage") |
| 208 | } |
| 209 | for _, s := range storageType { |
| 210 | cmd := fmt.Sprintf( |
| 211 | "kubectl patch cluster %v -n %v -p '{\"spec\":{\"%v\":{\"size\":\"2Gi\"}}}' --type=merge", |
| 212 | clusterName, |
| 213 | namespace, |
| 214 | s, |
| 215 | ) |
| 216 | Eventually(func() error { |
| 217 | _, _, err := run.Unchecked(cmd) |
| 218 | return err |
| 219 | }, 60, 5).Should(Succeed()) |
| 220 | } |
| 221 | }) |
| 222 | By("deleting Pod and PVCs, first replicas then the primary", func() { |
| 223 | // Gathering cluster primary |
| 224 | currentPrimary, err := clusterutils.GetPrimary(env.Ctx, env.Client, namespace, clusterName) |
| 225 | Expect(err).ToNot(HaveOccurred()) |
| 226 | currentPrimaryWalStorageName := currentPrimary.Name + "-wal" |
| 227 | quickDelete := &ctrlclient.DeleteOptions{ |
| 228 | GracePeriodSeconds: &quickDeletionPeriod, |
| 229 | } |
| 230 | |
| 231 | podList, err := clusterutils.ListPods(env.Ctx, env.Client, namespace, clusterName) |
| 232 | Expect(err).ToNot(HaveOccurred()) |
| 233 | Expect(len(podList.Items), err).To(BeEquivalentTo(3)) |
| 234 | |
| 235 | // Iterating through PVC list for deleting pod and PVC for storage expansion |
| 236 | for _, p := range podList.Items { |
| 237 | // Comparing cluster pods to not be primary to ensure cluster is healthy. |
| 238 | // Primary will be eventually deleted |
| 239 | if !specs.IsPodPrimary(p) { |
| 240 | // Deleting PVC |
| 241 | _, _, err = run.Run( |
| 242 | "kubectl delete pvc " + p.Name + " -n " + namespace + " --wait=false", |
| 243 | ) |
no test coverage detected