Bladeren bron

fix login and logout issue in CI

CYRIL AJIEH 3 jaren geleden
bovenliggende
commit
4ecb88d960
2 gewijzigde bestanden met toevoegingen van 47 en 63 verwijderingen
  1. 41 60
      integration-tests/tests/example-page.cy.ts
  2. 6 3
      test-prow-e2e.sh

+ 41 - 60
integration-tests/tests/example-page.cy.ts

@@ -12,7 +12,7 @@ const installHelmChart = (path: string) => {
       failOnNonZeroExit: false,
     },
   ).then((result) => {
-    cy.visit(`/example`);
+    cy.visit(`/dashboards`);
     cy.log('Error installing helm chart: ', result.stderr);
     cy.log('Successfully installed helm chart: ', result.stdout);
   });
@@ -30,70 +30,51 @@ const deleteHelmChart = (path: string) => {
   });
 };
 
-// Adding this to further debug the failing test issues in CI
-describe('My First Test without installing hel chart', () => {
-  it('Does not do much! Should pass', () => {
-    expect(true).to.equal(true);
-  });
-  it('Does not do much! Should fail', () => {
-    expect(true).to.equal(false);
-  });
-});
-
-if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_TEMPLATE_PULL_SPEC')) {
-  describe('Console plugin template test', () => {
-    before(() => {
-      cy.login();
+describe('Console plugin template test', () => {
+  before(() => {
+    cy.login();
 
-      if (!isLocalDevEnvironment) {
-        console.log('this is not a local env, installig helm');
+    if (!isLocalDevEnvironment) {
+      console.log('this is not a local env, installig helm');
 
-        cy.exec('cd ../../console-plugin-template && ./install_helm.sh', {
-          failOnNonZeroExit: false,
-        }).then((result) => {
-          cy.log('Error installing helm binary: ', result.stderr);
-          cy.log(
-            'Successfully installed helm binary in "/tmp" directory: ',
-            result.stdout,
-          );
+      cy.exec('cd ../../console-plugin-template && ./install_helm.sh', {
+        failOnNonZeroExit: false,
+      }).then((result) => {
+        cy.log('Error installing helm binary: ', result.stderr);
+        cy.log(
+          'Successfully installed helm binary in "/tmp" directory: ',
+          result.stdout,
+        );
 
-          installHelmChart('/tmp/helm');
-        });
-      } else {
-        console.log('this is a local env, not installing helm');
+        installHelmChart('/tmp/helm');
+      });
+    } else {
+      console.log('this is a local env, not installing helm');
 
-        installHelmChart('helm');
-      }
-    });
+      installHelmChart('helm');
+    }
+  });
 
-    afterEach(() => {
-      checkErrors();
-      cy.logout();
-    });
+  afterEach(() => {
+    checkErrors();
+  });
 
-    after(() => {
-      cy.logout();
-      if (!isLocalDevEnvironment) {
-        deleteHelmChart('/tmp/helm');
-      } else {
-        deleteHelmChart('helm');
-      }
-    });
+  after(() => {
+    if (!isLocalDevEnvironment) {
+      deleteHelmChart('/tmp/helm');
+    } else {
+      deleteHelmChart('helm');
+    }
+    cy.logout();
+  });
 
-    it('Does not do much! Should pass', () => {
-      expect(true).to.equal(true);
-    });
-    it('Verify the example page title', () => {
-      cy.get('[data-quickstart-id="qs-nav-home"]').click();
-      cy.get('[data-test="nav"]').contains('Plugin Example').click();
-      cy.url().should('include', '/example');
-      cy.get('[data-test="example-page-title"]').should(
-        'contain',
-        'Hello, Plugin!',
-      );
-    });
-    it('Does not do much! Should fail', () => {
-      expect(true).to.equal(false);
-    });
+  it('Verify the example page title', () => {
+    cy.get('[data-quickstart-id="qs-nav-home"]').click();
+    cy.get('[data-test="nav"]').contains('Plugin Example').click();
+    cy.url().should('include', '/example');
+    cy.get('[data-test="example-page-title"]').should(
+      'contain',
+      'Hello, Plugin!',
+    );
   });
-}
+});

+ 6 - 3
test-prow-e2e.sh

@@ -8,14 +8,17 @@ INSTALLER_DIR=${INSTALLER_DIR:=${ARTIFACT_DIR}/installer}
 
 function copyArtifacts {
   if [ -d "$ARTIFACT_DIR" ] && [ -d "$SCREENSHOTS_DIR" ]; then
-    echo "Copying artifacts from $(pwd)..."
-    cp -r "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}"
+    if [[ -z "$(ls -A -- "$SCREENSHOTS_DIR")" ]]; then
+      echo "No artifacts were copied."
+    else
+      echo "Copying artifacts from $(pwd)..."
+      cp -r "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}/screenshots"
+    fi
   fi
 }
 
 trap copyArtifacts EXIT
 
-trap "yarn run cypress-postreport" EXIT
 
 # don't log kubeadmin-password
 set +x