@@ -21,28 +21,43 @@ export class GitLabProvider extends Utils {
21
21
22
22
// Function to find a repository by name
23
23
public async checkIfRepositoryExists ( namespace : string , repoName : string ) : Promise < number > {
24
- try {
25
- const projects = await this . gitlab . Projects . show ( `${ namespace } /${ repoName } ` ) ;
26
- console . info ( `Repository with name '${ repoName } ' found in namespace '${ namespace } '
27
- created at '${ projects . created_at } ' url: gitlab.com/${ namespace } /${ repoName } ` ) ;
24
+ //RHTAPBUGS-1327: Added wait: it should improve stability of Gitlab test - sometimes request from tests could be faster, than GitLab responses
25
+ while ( true ) {
26
+ try {
27
+ const projects = await this . gitlab . Projects . show ( `${ namespace } /${ repoName } ` ) ;
28
+ if ( projects ) {
29
+ console . info ( `Repository with name '${ repoName } ' found in namespace '${ namespace } '
30
+ created at '${ projects . created_at } ' url: gitlab.com/${ namespace } /${ repoName } ` ) ;
31
+ return projects . id
32
+ }
28
33
29
- return projects . id
30
- } catch ( error ) {
31
- console . error ( error ) ;
34
+ await this . sleep ( 5000 ) ; // Wait 5 seconds before checking again
35
+ } catch ( error ) {
36
+ console . info ( `Failed to check if repository ${ repoName } exists` ) ;
32
37
33
- throw new Error ( `Failed to check if repository ${ repoName } exists` ) ;
38
+ }
34
39
}
35
40
}
36
41
37
42
/**
38
43
* checkIfRepositoryHaveFolder
39
44
*/
40
45
public async checkIfRepositoryHaveFolder ( repositoryID : number , folderPath : string ) : Promise < boolean > {
41
- const file = await this . gitlab . Repositories . allRepositoryTrees ( repositoryID )
46
+ //RHTAPBUGS-1327: Added wait: it should improve stability of Gitlab test - sometimes request from tests could be faster, than GitLab responses
47
+ while ( true ) {
48
+ try {
49
+ const file = await this . gitlab . Repositories . allRepositoryTrees ( repositoryID )
50
+ if ( file ) {
51
+ return file . some ( ( folder ) => {
52
+ return folder . path === folderPath && folder . type === 'tree'
53
+ } )
54
+ }
42
55
43
- return file . some ( ( folder ) => {
44
- return folder . path === folderPath && folder . type === 'tree'
45
- } )
56
+ await this . sleep ( 5000 ) ; // Wait 5 seconds before checking again
57
+ } catch ( error ) {
58
+ console . info ( 'Error checking for folder creation' ) ;
59
+ }
60
+ }
46
61
}
47
62
48
63
/**
0 commit comments