[tests-only][full-ci] add retry logic for space creation and copy request (#12815)

* test: add retry once for space creation wherever required (#12785)

Signed-off-by: nabim777 <nabinalemagar019@gmail.com>

* test: add retry logic for file copy requests (#12781)

Signed-off-by: nabim777 <nabinalemagar019@gmail.com>

---------

Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
Co-authored-by: Nalem7 <61624650+nabim777@users.noreply.github.com>
This commit is contained in:
Prajwol AmatyaandNalem7 authored and GitHub committed 2026-08-20 11:14:14 +05:45
1 parent 2faf44b0db
commit 541e5824d2
2 files changed
+28 -3

No files matched your search

+27 -2
View File
@@ -1902,11 +1902,12 @@ class SpacesContext implements Context {
}
/**
* @Given /^user "([^"]*)" has created a space "([^"]*)"(| in vault)? with the default quota using the Graph API$/
* @Given /^user "([^"]*)" has created a space "([^"]*)"(| in vault)?(| with retry) with the default quota using the Graph API$/
*
* @param string $user
* @param string $spaceName
* @param string $isVault
* @param string $withRetry
*
* @return void
*
@@ -1917,10 +1918,22 @@ class SpacesContext implements Context {
string $user,
string $spaceName,
string $isVault,
string $withRetry,
): void {
$space = ["name" => $spaceName];
$isVault = trim($isVault) === "in vault";
$withRetry = trim($withRetry) === "with retry";
// The user role may take some time to update
// This can cause an unauthorized error
// Retry once after 1 second
$response = $this->createSpace($user, $space, $isVault);
if ($withRetry && $response->getStatusCode() === 401) {
sleep(1); // Wait 1 second before retrying.
$response = $this->createSpace($user, $space, $isVault);
}
$this->featureContext->theHTTPStatusCodeShouldBe(
201,
"Expected response status code should be 201 (Created)",
@@ -2561,7 +2574,19 @@ class SpacesContext implements Context {
}
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
if ($actionType === 'copied') {
$response = $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
// while performing copy operation,
// sometime it will return 500 error.
// So we need to retry the copy operation.
$maxAttempts = 3;
for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
$response = $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
if ($response->getStatusCode() !== 500) {
break;
}
if ($attempt < $maxAttempts) {
\sleep(1);
}
}
} else {
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
}
@@ -834,7 +834,7 @@ Feature: collaboration (wopi)
Scenario: user with Viewer role tries to create a odt file inside shared project space using wopi endpoint
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a space "new-space" with retry with the default quota using the Graph API
And user "Alice" has created a folder "testFolder" in space "new-space"
And user "Alice" has sent the following space share invitation:
| space | new-space |