Skip to content

Commit

Permalink
fix: failing smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Oct 16, 2023
1 parent 5c5c1ee commit bb0207f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 113 deletions.
218 changes: 109 additions & 109 deletions .github/workflows/smoke_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
name: Smoke Tests
on:
push:
branches:
- master
pull_request:

jobs:
smoke_tests:
name: Smoke tests @ Nexus ${{ matrix.nexus_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nexus_version: [3.34.1]

steps:
- name: Fetch sources
uses: actions/checkout@v2

- name: Setup JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Configure build metadata
id: metadata
run: echo ::set-output name=tag::1.0.0

# - name: Install Cypress
# run: npm install -g [email protected]

# - name: Build plugin
# env:
# TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
# TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
# run: |
# ./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
# ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar

# - name: Start the Nexus container with Snyk plugin mounted
# run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

# - name: Wait for Nexus start
# run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

# - name: Wait for API status endpoint
# run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

# - name: Run Cypress to log in to Nexus and set up Snyk plugin
# working-directory: test/smoke
# run: |
# docker exec nexus cat /nexus-data/admin.password > /tmp/password
# export NEXUS_PASS=$(cat /tmp/password)
# echo $NEXUS_PASS
# cat /tmp/password
# cypress run
# env:
# TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
# TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}

- name: Setup npm
run: npm install

# - name: Lint Node.js
# run: npm run lint:formatting

- name: Run Jest tests against running Nexus
run: |
export NEXUS_PASS=$(cat /tmp/password)
npm run test
- uses: actions/upload-artifact@v2
if: always()
with:
name: screenshots
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/screenshots/cypress-test.spec.js/
retention-days: 1

- uses: actions/upload-artifact@v2
if: always()
with:
name: video
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/videos/cypress-test.spec.js.mp4
retention-days: 1

- name: Save docker logs to file
uses: jwalton/gh-docker-logs@v1
with:
dest: "./logs"

- name: Find any Snyk plugin errors in docker logs
run: "! grep -Hrni snyk ./logs | grep -i error"

- name: Dump docker logs (on success)
uses: jwalton/gh-docker-logs@v1

- name: Dump docker logs (on failure)
if: failure()
uses: jwalton/gh-docker-logs@v1
name: Smoke Tests
on:
push:
branches:
- master
pull_request:

jobs:
smoke_tests:
name: Smoke tests @ Nexus ${{ matrix.nexus_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nexus_version: [3.34.1]

steps:
- name: Fetch sources
uses: actions/checkout@v2

- name: Setup JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Configure build metadata
id: metadata
run: echo ::set-output name=tag::1.0.0

- name: Install Cypress
run: npm install -g [email protected]

- name: Build plugin
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
run: |
./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar
- name: Start the Nexus container with Snyk plugin mounted
run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

- name: Wait for Nexus start
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

- name: Wait for API status endpoint
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

- name: Run Cypress to log in to Nexus and set up Snyk plugin
working-directory: test/smoke
run: |
docker exec nexus cat /nexus-data/admin.password > /tmp/password
export NEXUS_PASS=$(cat /tmp/password)
echo $NEXUS_PASS
cat /tmp/password
cypress run --headless --browser chrome
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}

- name: Setup npm
run: npm install

- name: Lint Node.js
run: npm run lint:formatting

- name: Run Jest tests against running Nexus
run: |
export NEXUS_PASS=$(cat /tmp/password)
npm run test
- uses: actions/upload-artifact@v2
if: always()
with:
name: screenshots
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/screenshots/cypress-test.spec.js/
retention-days: 1

- uses: actions/upload-artifact@v2
if: always()
with:
name: video
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/videos/cypress-test.spec.js.mp4
retention-days: 1

- name: Save docker logs to file
uses: jwalton/gh-docker-logs@v1
with:
dest: "./logs"

- name: Find any Snyk plugin errors in docker logs
run: "! grep -Hrni snyk ./logs | grep -i error"

- name: Dump docker logs (on success)
uses: jwalton/gh-docker-logs@v1

- name: Dump docker logs (on failure)
if: failure()
uses: jwalton/gh-docker-logs@v1
3 changes: 2 additions & 1 deletion test/smoke/cypress/integration/cypress-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("test", () => {
"This wizard will help you complete required setup tasks."
).should("be.visible");

// Go through the mandatory wizard to set a new password (same as the old password)
// Go through the mandatory wizard to set a new password (same as the old password)
cy.get("body").then(($body) => {
if ($body.find('div[role="dialog"]').length) {
cy.log("found the wizard");
Expand Down Expand Up @@ -82,6 +82,7 @@ describe("test", () => {
cy.get('a[data-qtip="Server administration and configuration"]').click();
cy.contains('td[role="gridcell"]', "System").click();
cy.contains('div[role="option"]', "Capabilities").click();
cy.contains("Loading").should("not.be.visible");
cy.contains('a[role="button"]', "Create capability").click();
cy.contains("Loading").should("not.be.visible");
cy.contains("Select Capability Type").should("be.visible");
Expand Down
4 changes: 1 addition & 3 deletions test/the.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ it('can download a non-vulnerable package', async () => {
expect(res.status).toBe(200);
});

it.only('throws when trying to download a vulnerable package', async () => {
it('throws when trying to download a vulnerable package', async () => {
const url = buildNexusArtifactDownloadUrl(
'com.fasterxml.jackson.core',
'jackson-databind',
Expand All @@ -56,7 +56,5 @@ it.only('throws when trying to download a vulnerable package', async () => {
capturedErr = err;
}

console.log('****', 'res ****\n', JSON.stringify(res, null, 2), '\n');
console.log('****', 'capturedErr ****\n', JSON.stringify(capturedErr, null, 2), '\n');
expect(capturedErr.response.status).toEqual(500);
});

0 comments on commit bb0207f

Please sign in to comment.