Skip to content

Commit 01c23b1

Browse files
authored
Merge pull request #7391 from magento-arcticfoxes/B2B-2140
[Arcticfoxes] AWS S3 stabilization
2 parents cce616b + e8a9b41 commit 01c23b1

File tree

82 files changed

+658
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+658
-38
lines changed

app/code/Magento/AwsS3/Test/Mftf/Helper/FileAssertions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ public function copy($source, $destination): void
9999
$this->helperInstance->copy($this->extractFilePath($source), $this->extractFilePath($destination));
100100
}
101101

102+
/**
103+
* {@inheritDoc}
104+
*
105+
* @param string $source - path to local file or json structure with paths by storage type.
106+
* @param string $destination - path to file or json structure with paths by storage type.
107+
* @throws \Magento\Framework\Exception\FileSystemException
108+
*/
109+
public function copyFromLocal($source, $destination): void
110+
{
111+
$this->helperInstance->copyFromLocal($this->extractFilePath($source), $this->extractFilePath($destination));
112+
}
113+
102114
/**
103115
* Create directory in the storage
104116
*

app/code/Magento/AwsS3/Test/Mftf/Helper/FileAssertionsInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ public function deleteFileIfExists($filePath): void;
4444
*/
4545
public function copy($source, $destination): void;
4646

47+
/**
48+
* Copy file from the local source into local or remote destination depends on storage FS
49+
*
50+
* @param string $source
51+
* @param string $destination
52+
* @return void
53+
*
54+
* @throws \Magento\Framework\Exception\FileSystemException
55+
*/
56+
public function copyFromLocal($source, $destination): void;
57+
4758
/**
4859
* Create directory in the storage
4960
*

app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ public function copy($source, $destination): void
110110
$this->driver->copy($source, $destination);
111111
}
112112

113+
/**
114+
* Copy file from the local source into AWS S3 $destination
115+
*
116+
* @param string $source local FS path to the file which should be copied
117+
* @param string $destination path on AWS S3 where the file should be paste
118+
* @return void
119+
*
120+
* @throws \Magento\Framework\Exception\FileSystemException
121+
*/
122+
public function copyFromLocal($source, $destination): void
123+
{
124+
$this->driver->filePutContents(
125+
$destination,
126+
file_get_contents((substr($source, 0, 1) === '/') ? $source : MAGENTO_BP . '/' . $source)
127+
);
128+
}
129+
113130
/**
114131
* Create directory in the S3 bucket
115132
*
@@ -165,7 +182,10 @@ public function assertFileExists($filePath, $message = ''): void
165182
public function assertGlobbedFileExists($path, $pattern, $message = ''): void
166183
{
167184
$files = $this->driver->search($pattern, $path);
168-
$this->assertNotEmpty($files, "Failed asserting file matching glob pattern \"$pattern\" at location \"$path\" is not empty. " . $message);
185+
$this->assertNotEmpty(
186+
$files,
187+
"Failed asserting file matching glob pattern \"$pattern\" at location \"$path\" is not empty. " . $message
188+
);
169189
}
170190

171191
/**
@@ -221,7 +241,10 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
221241
*/
222242
public function assertFileEmpty($filePath, $message = ''): void
223243
{
224-
$this->assertEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is empty. " . $message);
244+
$this->assertEmpty(
245+
$this->driver->fileGetContents($filePath),
246+
"Failed asserting $filePath is empty. " . $message
247+
);
225248
}
226249

227250
/**
@@ -235,7 +258,10 @@ public function assertFileEmpty($filePath, $message = ''): void
235258
*/
236259
public function assertFileNotEmpty($filePath, $message = ''): void
237260
{
238-
$this->assertNotEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is not empty. " . $message);
261+
$this->assertNotEmpty(
262+
$this->driver->fileGetContents($filePath),
263+
"Failed asserting $filePath is not empty. " . $message
264+
);
239265
}
240266

241267
/**
@@ -250,11 +276,16 @@ public function assertFileNotEmpty($filePath, $message = ''): void
250276
*/
251277
public function assertFileContainsString($filePath, $text, $message = ''): void
252278
{
253-
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath contains $text. " . $message);
279+
$this->assertStringContainsString(
280+
$text,
281+
$this->driver->fileGetContents($filePath),
282+
"Failed asserting $filePath contains $text. " . $message
283+
);
254284
}
255285

256286
/**
257-
* Asserts that a file with the given glob pattern at the given path on the remote storage system contains a given string
287+
* Asserts that a file with the given glob pattern at the given path
288+
* on the remote storage system contains a given string
258289
*
259290
* @param string $path
260291
* @param string $pattern
@@ -268,7 +299,12 @@ public function assertFileContainsString($filePath, $text, $message = ''): void
268299
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ''): void
269300
{
270301
$files = $this->driver->search($pattern, $path);
271-
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), "Failed asserting file of index \"$fileIndex\" matching glob pattern \"$pattern\" at location \"$path\" contains $text. " . $message);
302+
$this->assertStringContainsString(
303+
$text,
304+
$this->driver->fileGetContents($files[$fileIndex] ?? ''),
305+
"Failed asserting file of index \"$fileIndex\" matching glob pattern \"$pattern\""
306+
. " at location \"$path\" contains $text. " . $message
307+
);
272308
}
273309

274310
/**
@@ -283,7 +319,11 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
283319
*/
284320
public function assertFileDoesNotContainString($filePath, $text, $message = ''): void
285321
{
286-
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath does not contain $text. " . $message);
322+
$this->assertStringNotContainsString(
323+
$text,
324+
$this->driver->fileGetContents($filePath),
325+
"Failed asserting $filePath does not contain $text. " . $message
326+
);
287327
}
288328

289329
/**

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportBundleProductTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<testCaseId value="MC-38558"/>
2525
<group value="importExport"/>
2626
<group value="remote_storage_aws_s3"/>
27+
<group value="skip_in_cloud_native_s3"/>
2728
</annotations>
2829

2930
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportDownloadableProductWithFileLinksTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<testCaseId value="MC-38558"/>
2626
<group value="importExport"/>
2727
<group value="remote_storage_aws_s3"/>
28+
<group value="skip_in_cloud_native_s3"/>
2829
</annotations>
2930

3031
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportDownloadableProductWithURLLinksTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<testCaseId value="MC-38558"/>
2626
<group value="importExport"/>
2727
<group value="remote_storage_aws_s3"/>
28+
<group value="skip_in_cloud_native_s3"/>
2829
</annotations>
2930

3031
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportGroupedProductWithSpecialPriceTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<testCaseId value="MC-38558"/>
2525
<group value="importExport"/>
2626
<group value="remote_storage_aws_s3"/>
27+
<group value="skip_in_cloud_native_s3"/>
2728
</annotations>
2829

2930
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<testCaseId value="MC-38558"/>
2626
<group value="importExport"/>
2727
<group value="remote_storage_aws_s3"/>
28+
<group value="skip_in_cloud_native_s3"/>
2829
</annotations>
2930

3031
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<testCaseId value="MC-38558"/>
2626
<group value="importExport"/>
2727
<group value="remote_storage_aws_s3"/>
28+
<group value="skip_in_cloud_native_s3"/>
2829
</annotations>
2930

3031
<before>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ExportTaxRatesTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<group value="importExport"/>
2626
<group value="tax"/>
2727
<group value="remote_storage_aws_s3"/>
28+
<group value="skip_in_cloud_native_s3"/>
2829
<group value="pr_exclude"/>
2930
</annotations>
3031

0 commit comments

Comments
 (0)