@@ -15,11 +15,13 @@ limitations under the License.
15
15
package e2e
16
16
17
17
import (
18
+ "context"
18
19
"fmt"
19
20
"log"
20
21
"math/rand"
21
22
"os"
22
23
"strings"
24
+ "time"
23
25
24
26
. "github.com/onsi/ginkgo"
25
27
v1 "k8s.io/api/core/v1"
@@ -31,13 +33,16 @@ import (
31
33
"github.com/outscale-dev/osc-bsu-csi-driver/tests/e2e/driver"
32
34
"github.com/outscale-dev/osc-bsu-csi-driver/tests/e2e/testsuites"
33
35
36
+ "github.com/outscale-dev/osc-bsu-csi-driver/pkg/cloud"
34
37
osccloud "github.com/outscale-dev/osc-bsu-csi-driver/pkg/cloud"
35
38
bsucsidriver "github.com/outscale-dev/osc-bsu-csi-driver/pkg/driver"
36
39
"k8s.io/apimachinery/pkg/runtime"
37
40
"k8s.io/apimachinery/pkg/runtime/schema"
38
41
"k8s.io/apimachinery/pkg/runtime/serializer"
39
42
)
40
43
44
+ const OSC_REGION = "OSC_REGION"
45
+
41
46
var _ = Describe ("[bsu-csi-e2e] [single-az] Dynamic Provisioning" , func () {
42
47
f := framework .NewDefaultFramework ("bsu" )
43
48
@@ -539,6 +544,49 @@ var _ = Describe("[bsu-csi-e2e] [single-az] Dynamic Provisioning", func() {
539
544
540
545
test .Run (cs , ns , f )
541
546
})
547
+
548
+ It ("should create a volume, delete it from outside and release the volume" , func () {
549
+ binding := storagev1 .VolumeBindingImmediate
550
+ retain := v1 .PersistentVolumeReclaimDelete
551
+ volume := testsuites.VolumeDetails {
552
+ VolumeType : osccloud .VolumeTypeGP2 ,
553
+ FSType : bsucsidriver .FSTypeExt4 ,
554
+ ClaimSize : driver .MinimumSizeForVolumeType (osccloud .VolumeTypeGP2 ),
555
+ VolumeBindingMode : & binding ,
556
+ ReclaimPolicy : & retain ,
557
+ }
558
+
559
+ By ("Create the PVC" )
560
+ tpvc , cleanups := volume .SetupDynamicPersistentVolumeClaim (cs , ns , bsuDriver )
561
+ for i := range cleanups {
562
+ defer cleanups [i ]()
563
+ }
564
+
565
+ tpvc .WaitForBound ()
566
+
567
+ if os .Getenv (OSC_REGION ) == "" {
568
+ Skip (fmt .Sprintf ("env %q not set" , OSC_REGION ))
569
+ }
570
+
571
+ By ("Create the cloud" )
572
+
573
+ oscCloud , err := osccloud .NewCloudWithoutMetadata (os .Getenv (OSC_REGION ))
574
+ framework .ExpectNoError (err , "Error while creating a cloud configuration" )
575
+
576
+ By ("Keep delete the disk until error" )
577
+ tpvc .DeleteBackingVolume (oscCloud )
578
+
579
+ pv := tpvc .GetPersistentVolume ()
580
+ for i := 1 ; i < 100 ; i ++ {
581
+ _ , err := oscCloud .DeleteDisk (context .Background (), pv .Spec .CSI .VolumeHandle )
582
+ if err == cloud .ErrNotFound {
583
+ break
584
+ }
585
+ fmt .Println ("Disk still present, waiting" )
586
+ time .Sleep (1 * time .Second )
587
+ }
588
+
589
+ })
542
590
})
543
591
544
592
var _ = Describe ("[bsu-csi-e2e] [single-az] Snapshot" , func () {
@@ -599,6 +647,60 @@ var _ = Describe("[bsu-csi-e2e] [single-az] Snapshot", func() {
599
647
}
600
648
test .Run (cs , snapshotrcs , ns )
601
649
})
650
+
651
+ It ("should create a snapshot, delete it from outside and release the snapshot" , func () {
652
+ binding := storagev1 .VolumeBindingImmediate
653
+ retain := v1 .PersistentVolumeReclaimDelete
654
+ volume := testsuites.VolumeDetails {
655
+ VolumeType : osccloud .VolumeTypeGP2 ,
656
+ FSType : bsucsidriver .FSTypeExt4 ,
657
+ ClaimSize : driver .MinimumSizeForVolumeType (osccloud .VolumeTypeGP2 ),
658
+ VolumeBindingMode : & binding ,
659
+ ReclaimPolicy : & retain ,
660
+ }
661
+
662
+ By ("Create the PVC" )
663
+ tpvc , cleanups := volume .SetupDynamicPersistentVolumeClaim (cs , ns , bsuDriver )
664
+ for i := range cleanups {
665
+ defer cleanups [i ]()
666
+ }
667
+
668
+ pvc := tpvc .WaitForBound ()
669
+
670
+ if os .Getenv (OSC_REGION ) == "" {
671
+ Skip (fmt .Sprintf ("env %q not set" , OSC_REGION ))
672
+ }
673
+
674
+ By ("Create the Snapshot" )
675
+ tvsc , cleanup := testsuites .CreateVolumeSnapshotClass (snapshotrcs , ns , bsuDriver )
676
+ defer cleanup ()
677
+ snapshot := tvsc .CreateSnapshot (& pvc )
678
+ defer tvsc .DeleteSnapshot (snapshot )
679
+ tvsc .ReadyToUse (snapshot )
680
+
681
+ By ("Create the cloud" )
682
+ oscCloud , err := osccloud .NewCloudWithoutMetadata (os .Getenv (OSC_REGION ))
683
+ framework .ExpectNoError (err , "Error while creating a cloud configuration" )
684
+
685
+ By ("Retrieve the snapshot" )
686
+ snap , err := oscCloud .GetSnapshotByName (context .Background (), fmt .Sprintf ("snapshot-%v" , snapshot .UID ))
687
+ framework .ExpectNoError (err , fmt .Sprintf ("Error while retrieving snapshot %v" , snapshot .UID ))
688
+
689
+ By ("Deleting the snapshot" )
690
+ _ , err = oscCloud .DeleteSnapshot (context .Background (), snap .SnapshotID )
691
+ framework .ExpectNoError (err , fmt .Sprintf ("Error while deleting snapshot %v" , snap .SnapshotID ))
692
+
693
+ By ("Keep deleting the snapshot until error" )
694
+ for i := 1 ; i < 100 ; i ++ {
695
+ _ , err := oscCloud .DeleteSnapshot (context .Background (), snap .SnapshotID )
696
+ if err == cloud .ErrNotFound {
697
+ break
698
+ }
699
+ fmt .Println ("Snapshot still present, waiting" )
700
+ time .Sleep (1 * time .Second )
701
+ }
702
+
703
+ })
602
704
})
603
705
604
706
var _ = Describe ("[bsu-csi-e2e] [multi-az] Dynamic Provisioning" , func () {
0 commit comments