@@ -5,7 +5,7 @@ import { GitLabProvider } from "../../../../src/apis/git-providers/gitlab";
5
5
import { Kubernetes } from "../../../../src/apis/kubernetes/kube" ;
6
6
import { ScaffolderScaffoldOptions } from "@backstage/plugin-scaffolder-react" ;
7
7
import { generateRandomChars } from "../../../../src/utils/generator" ;
8
- import { cleanAfterTestGitLab , getDeveloperHubClient , getGitLabProvider , getRHTAPRootNamespace , waitForStringInPageContent } from "../../../../src/utils/test.utils" ;
8
+ import { cleanAfterTestGitLab , getCosignPassword , getCosignPrivateKey , getCosignPublicKey , getDeveloperHubClient , getGitLabProvider , getRHTAPRootNamespace , waitForArgoSyncAndRouteContent , waitForComponentCreation , waitForStringInPageContent } from "../../../../src/utils/test.utils" ;
9
9
import { syncArgoApplication } from "../../../../src/utils/argocd" ;
10
10
11
11
/**
@@ -113,20 +113,7 @@ export const gitLabProviderGitLabCITests = (softwareTemplateName: string, string
113
113
* If the task is not completed within the timeout, it writes logs to the specified directory.
114
114
*/
115
115
it ( `waits for ${ softwareTemplateName } component creation to finish` , async ( ) => {
116
- const taskCreated = await backstageClient . getTaskProcessed ( developerHubTask . id , 120000 )
117
-
118
- if ( taskCreated . status !== 'completed' ) {
119
- console . log ( "Failed to create backstage task. Creating logs..." ) ;
120
-
121
- try {
122
- const logs = await backstageClient . getEventStreamLog ( taskCreated . id )
123
- await backstageClient . writeLogsToArtifactDir ( 'backstage-tasks-logs' , `gitlab-${ repositoryName } .log` , logs )
124
- } catch ( error ) {
125
- throw new Error ( `Failed to write logs to artifact directory: ${ error } ` ) ;
126
- }
127
- } else {
128
- console . log ( "Task created successfully in backstage" ) ;
129
- }
116
+ await waitForComponentCreation ( backstageClient , repositoryName , developerHubTask ) ;
130
117
} , 120000 ) ;
131
118
132
119
/**
@@ -162,9 +149,9 @@ export const gitLabProviderGitLabCITests = (softwareTemplateName: string, string
162
149
* Waits for the specified ArgoCD application associated with the DeveloperHub task to be synchronized in the cluster.
163
150
*/
164
151
it ( `Setup creds for ${ softwareTemplateName } pipeline` , async ( ) => {
165
- await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_PUBLIC_KEY" , await kubeClient . getCosignPublicKey ( ) ) ;
166
- await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_SECRET_KEY" , await kubeClient . getCosignPrivateKey ( ) ) ;
167
- await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_SECRET_PASSWORD" , await kubeClient . getCosignPassword ( ) ) ;
152
+ await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_PUBLIC_KEY" , await getCosignPublicKey ( kubeClient ) ) ;
153
+ await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_SECRET_KEY" , await getCosignPrivateKey ( kubeClient ) ) ;
154
+ await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "COSIGN_SECRET_PASSWORD" , await getCosignPassword ( kubeClient ) ) ;
168
155
await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "GITOPS_AUTH_USERNAME" , 'fakeUsername' ) ;
169
156
await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "GITOPS_AUTH_PASSWORD" , await gitLabProvider . getGitlabToken ( ) ) ;
170
157
await gitLabProvider . setEnvironmentVariable ( gitlabRepositoryID , "QUAY_IO_CREDS_PSW" , process . env . QUAY_PASSWORD || '' ) ;
@@ -199,14 +186,7 @@ export const gitLabProviderGitLabCITests = (softwareTemplateName: string, string
199
186
* Obtain the openshift Route for the component and verify that the previous builded image was synced in the cluster and deployed in development environment
200
187
*/
201
188
it ( 'container component is successfully synced by gitops in development environment' , async ( ) => {
202
- console . log ( "syncing argocd application in development environment" )
203
- await syncArgoApplication ( RHTAPRootNamespace , `${ repositoryName } -${ developmentEnvironmentName } ` )
204
- const componentRoute = await kubeClient . getOpenshiftRoute ( repositoryName , developmentNamespace )
205
- const isReady = await backstageClient . waitUntilComponentEndpointBecomeReady ( `https://${ componentRoute } ` , 10 * 60 * 1000 )
206
- if ( ! isReady ) {
207
- throw new Error ( "Component seems was not synced by ArgoCD in 10 minutes" ) ;
208
- }
209
- expect ( await waitForStringInPageContent ( `https://${ componentRoute } ` , stringOnRoute , 120000 ) ) . toBe ( true )
189
+ await waitForArgoSyncAndRouteContent ( kubeClient , backstageClient , developmentNamespace , developmentEnvironmentName , repositoryName , stringOnRoute ) ;
210
190
} , 900000 )
211
191
212
192
/**
0 commit comments