-
Notifications
You must be signed in to change notification settings - Fork 20
/
vpc_create_volume_with_encryption.go
81 lines (72 loc) · 2.71 KB
/
vpc_create_volume_with_encryption.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
* IBM Confidential
* OCO Source Materials
* IBM Cloud Container Service, 5737-D43
* (C) Copyright IBM Corp. 2018 All Rights Reserved.
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with
* the U.S. Copyright Office.
******************************************************************************/
package vpc
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"go.uber.org/zap"
"time"
"github.com/IBM/ibmcloud-storage-volume-lib/lib/provider"
)
var _ = Describe("ibmcloud-storage-volume-lib", func() {
var (
volume *provider.Volume
)
AfterEach(func() {
sess.DeleteVolume(volume)
})
It("VPC: Create and delete VPC volume[with encryption]", func() {
volName := volumeName + "with-encryption"
volSize := volumeSize
Iops := iops
volume = &provider.Volume{}
volume.VolumeType = volumeType
volume.VPCVolume.ResourceGroup = &provider.ResourceGroup{}
profile := vpcProfile
volume.VPCVolume.Profile = &provider.Profile{Name: profile}
volume.Name = &volName
volume.Capacity = &volSize
volume.Iops = &Iops
volume.VPCVolume.ResourceGroup.ID = resourceGroupID
volume.Az = vpcZone
volume.VPCVolume.VolumeEncryptionKey = &provider.VolumeEncryptionKey{}
volume.VPCVolume.VolumeEncryptionKey.CRN = volumeEncryptionKeyCRN
volume.VPCVolume.Tags = []string{"Testing VPC volume from library with encryption"}
By("Test Create Volume")
startTime = time.Now()
volumeObj, err := sess.CreateVolume(*volume)
if err == nil {
Expect(err).NotTo(HaveOccurred())
ctxLogger.Info("Successfully created volume...", zap.Reflect("volumeObj", volumeObj))
} else {
err = updateRequestID(err, requestID)
ctxLogger.Info("Failed to create volume...", zap.Reflect("StorageType", volume.ProviderType), zap.Reflect("Error", err))
Expect(err).To(HaveOccurred())
}
ctxLogger.Info("Test Create Volume", zap.Reflect("Elapsed time:", fmt.Sprintf("%s", time.Since(startTime))))
fmt.Printf("\n\n")
volume = &provider.Volume{}
volume.VolumeID = volumeObj.VolumeID
By("Test Delete Volume")
startTime = time.Now()
err = sess.DeleteVolume(volume)
if err == nil {
Expect(err).NotTo(HaveOccurred())
ctxLogger.Info("Successfully deleted volume...", zap.Reflect("volumeObj", volume))
} else {
err = updateRequestID(err, requestID)
ctxLogger.Info("Failed to delete volume...", zap.Reflect("StorageType", volume.VolumeID), zap.Reflect("Error", err))
Expect(err).To(HaveOccurred())
}
ctxLogger.Info("Test Delete Volume", zap.Reflect("Elapsed time:", fmt.Sprintf("%s", time.Since(startTime))))
fmt.Printf("\n\n")
})
})