|
| 1 | +package cloudstorages |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | +) |
| 7 | + |
| 8 | +var _ = Describe("GetName", func() { |
| 9 | + var ( |
| 10 | + provider string |
| 11 | + expectedValue string |
| 12 | + ) |
| 13 | + BeforeEach(func() { |
| 14 | + provider = "aws" |
| 15 | + expectedValue = "aws" |
| 16 | + }) |
| 17 | + Context("Provider is aws", func() { |
| 18 | + It("should get provider name = aws", func() { |
| 19 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 20 | + Expect(csp.GetName()).To(Equal(expectedValue)) |
| 21 | + }) |
| 22 | + }) |
| 23 | +}) |
| 24 | + |
| 25 | +var _ = Describe("GetCloudStoragePath", func() { |
| 26 | + var ( |
| 27 | + provider string |
| 28 | + bucket string |
| 29 | + gatlingName string |
| 30 | + subDir string |
| 31 | + expectedValue string |
| 32 | + ) |
| 33 | + BeforeEach(func() { |
| 34 | + provider = "aws" |
| 35 | + bucket = "testBucket" |
| 36 | + gatlingName = "testGatling" |
| 37 | + subDir = "subDir" |
| 38 | + expectedValue = "s3:testBucket/testGatling/subDir" |
| 39 | + }) |
| 40 | + Context("Provider is aws", func() { |
| 41 | + It("path is aws s3 bucket", func() { |
| 42 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 43 | + Expect(csp.GetCloudStoragePath(bucket, gatlingName, subDir)).To(Equal(expectedValue)) |
| 44 | + }) |
| 45 | + }) |
| 46 | +}) |
| 47 | + |
| 48 | +var _ = Describe("GetCloudStorageReportURL", func() { |
| 49 | + var ( |
| 50 | + provider string |
| 51 | + bucket string |
| 52 | + gatlingName string |
| 53 | + subDir string |
| 54 | + expectedValue string |
| 55 | + ) |
| 56 | + BeforeEach(func() { |
| 57 | + provider = "aws" |
| 58 | + bucket = "testBucket" |
| 59 | + gatlingName = "testGatling" |
| 60 | + subDir = "subDir" |
| 61 | + expectedValue = "https://testBucket.s3.amazonaws.com/testGatling/subDir/index.html" |
| 62 | + }) |
| 63 | + Context("Provider is aws", func() { |
| 64 | + It("path is aws s3 bucket", func() { |
| 65 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 66 | + Expect(csp.GetCloudStorageReportURL(bucket, gatlingName, subDir)).To(Equal(expectedValue)) |
| 67 | + }) |
| 68 | + }) |
| 69 | +}) |
| 70 | + |
| 71 | +var _ = Describe("GetGatlingTransferResultCommand", func() { |
| 72 | + var ( |
| 73 | + provider string |
| 74 | + resultsDirectoryPath string |
| 75 | + region string |
| 76 | + storagePath string |
| 77 | + expectedValue string |
| 78 | + ) |
| 79 | + BeforeEach(func() { |
| 80 | + provider = "aws" |
| 81 | + resultsDirectoryPath = "testResultsDirectoryPath" |
| 82 | + region = "ap-northeast-1" |
| 83 | + storagePath = "testStoragePath" |
| 84 | + expectedValue = ` |
| 85 | +RESULTS_DIR_PATH=testResultsDirectoryPath |
| 86 | +rclone config create s3 s3 env_auth=true region ap-northeast-1 |
| 87 | +for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log) |
| 88 | +do |
| 89 | + rclone copyto ${source} --s3-no-check-bucket --s3-env-auth testStoragePath/${HOSTNAME}.log |
| 90 | +done |
| 91 | +` |
| 92 | + }) |
| 93 | + Context("Provider is aws", func() { |
| 94 | + It("returns commands with s3 rclone config", func() { |
| 95 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 96 | + Expect(csp.GetGatlingTransferResultCommand(resultsDirectoryPath, region, storagePath)).To(Equal(expectedValue)) |
| 97 | + }) |
| 98 | + }) |
| 99 | +}) |
| 100 | + |
| 101 | +var _ = Describe("GetGatlingAggregateResultCommand", func() { |
| 102 | + var ( |
| 103 | + provider string |
| 104 | + resultsDirectoryPath string |
| 105 | + region string |
| 106 | + storagePath string |
| 107 | + expectedValue string |
| 108 | + ) |
| 109 | + BeforeEach(func() { |
| 110 | + provider = "aws" |
| 111 | + resultsDirectoryPath = "testResultsDirectoryPath" |
| 112 | + region = "ap-northeast-1" |
| 113 | + storagePath = "testStoragePath" |
| 114 | + expectedValue = ` |
| 115 | +GATLING_AGGREGATE_DIR=testResultsDirectoryPath |
| 116 | +rclone config create s3 s3 env_auth=true region ap-northeast-1 |
| 117 | +rclone copy --s3-no-check-bucket --s3-env-auth testStoragePath ${GATLING_AGGREGATE_DIR} |
| 118 | +` |
| 119 | + }) |
| 120 | + Context("Provider is aws", func() { |
| 121 | + It("returns commands with s3 rclone config", func() { |
| 122 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 123 | + Expect(csp.GetGatlingAggregateResultCommand(resultsDirectoryPath, region, storagePath)).To(Equal(expectedValue)) |
| 124 | + }) |
| 125 | + }) |
| 126 | +}) |
| 127 | + |
| 128 | +var _ = Describe("GetGatlingTransferReportCommand", func() { |
| 129 | + var ( |
| 130 | + provider string |
| 131 | + resultsDirectoryPath string |
| 132 | + region string |
| 133 | + storagePath string |
| 134 | + expectedValue string |
| 135 | + ) |
| 136 | + BeforeEach(func() { |
| 137 | + provider = "aws" |
| 138 | + resultsDirectoryPath = "testResultsDirectoryPath" |
| 139 | + region = "ap-northeast-1" |
| 140 | + storagePath = "testStoragePath" |
| 141 | + expectedValue = ` |
| 142 | +GATLING_AGGREGATE_DIR=testResultsDirectoryPath |
| 143 | +rclone config create s3 s3 env_auth=true region ap-northeast-1 |
| 144 | +rclone copy ${GATLING_AGGREGATE_DIR} --exclude "*.log" --s3-no-check-bucket --s3-env-auth testStoragePath |
| 145 | +` |
| 146 | + }) |
| 147 | + Context("Provider is aws", func() { |
| 148 | + It("returns commands with s3 rclone config", func() { |
| 149 | + csp := &AWSCloudStorageProvider{providerName: provider} |
| 150 | + Expect(csp.GetGatlingTransferReportCommand(resultsDirectoryPath, region, storagePath)).To(Equal(expectedValue)) |
| 151 | + }) |
| 152 | + }) |
| 153 | +}) |
0 commit comments