From 55e8a94441d61e4ab5cb66c73e7e66e8b5b3433f Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 14:39:04 -0700 Subject: [PATCH 01/13] run tests in parallel across 3 machines --- .github/workflows/main.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89ed704..e7fcc3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,11 +3,15 @@ on: push jobs: cypress-run: runs-on: ubuntu-22.04 - # Cypress Docker image from https://hub.docker.com/r/cypress - # with browsers pre-installed - container: - image: cypress/browsers:latest - options: --user 1001 + strategy: + # when one test fails, DO NOT cancel the other + # containers, because this will kill Cypress processes + # leaving Cypress Cloud hanging ... + # https://github.com/cypress-io/github-action/issues/48 + fail-fast: false + matrix: + # run 3 copies of the current job in parallel + containers: [1, 2, 3] steps: - name: Checkout uses: actions/checkout@v4 @@ -19,6 +23,8 @@ jobs: # quote the url to be safe against YML parsing surprises wait-on: "http://localhost:3001" record: true + parallel: true + group: "Actions example" env: # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1956a9597d76dbc146dde682f7fd61080cf3d4a5 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 14:56:28 -0700 Subject: [PATCH 02/13] tweak config --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7fcc3e..349556c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,12 +19,12 @@ jobs: uses: cypress-io/github-action@v6 with: browser: chrome + record: true + parallel: true + group: "Chrome" start: npm start # quote the url to be safe against YML parsing surprises wait-on: "http://localhost:3001" - record: true - parallel: true - group: "Actions example" env: # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8436060e1b9f67a67dfff4ef363a7e12f5db529a Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 15:47:01 -0700 Subject: [PATCH 03/13] tweak config 2 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 349556c..5d190d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: # run 3 copies of the current job in parallel - containers: [1, 2, 3] + containers: [1, 2] steps: - name: Checkout uses: actions/checkout@v4 From 19e27f4b1430f6b9a0088caf4bd9da8d9b48d513 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 15:49:43 -0700 Subject: [PATCH 04/13] skipping test that fails in parallel config --- cypress/e2e/get_bookings.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index e963240..038bba8 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -55,7 +55,7 @@ describe("Get Bookings spec", () => { }); }); - it("Get Booking by Checkin", () => { + it.skip("Get Booking by Checkin", () => { bookings_wrapper .get_booking_by({ checkin: sampleCheckinStr }) .then((response) => { From 5a1ab4cd7907d5e7189ce1be60f1db019d563e7d Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 15:52:16 -0700 Subject: [PATCH 05/13] revert hack workarounds --- .github/workflows/main.yml | 2 +- cypress/e2e/get_bookings.cy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d190d0..349556c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: # run 3 copies of the current job in parallel - containers: [1, 2] + containers: [1, 2, 3] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index 038bba8..e963240 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -55,7 +55,7 @@ describe("Get Bookings spec", () => { }); }); - it.skip("Get Booking by Checkin", () => { + it("Get Booking by Checkin", () => { bookings_wrapper .get_booking_by({ checkin: sampleCheckinStr }) .then((response) => { From 569b3b50afe298610a63bb4fa684a524f702f564 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 16:03:08 -0700 Subject: [PATCH 06/13] hack workaround to add delay for failing test --- cypress/e2e/get_bookings.cy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index e963240..3a0ff69 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -56,6 +56,7 @@ describe("Get Bookings spec", () => { }); it("Get Booking by Checkin", () => { + cy.wait(1000); bookings_wrapper .get_booking_by({ checkin: sampleCheckinStr }) .then((response) => { From 6e3b909206090496a4ac143383c683dcd6be6e05 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Fri, 15 Mar 2024 16:08:30 -0700 Subject: [PATCH 07/13] revert wait hack and switch to mac from ubuntu --- .github/workflows/main.yml | 2 +- cypress/e2e/get_bookings.cy.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 349556c..4d05298 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Run API tests on: push jobs: cypress-run: - runs-on: ubuntu-22.04 + runs-on: macos-latest strategy: # when one test fails, DO NOT cancel the other # containers, because this will kill Cypress processes diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index 3a0ff69..e963240 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -56,7 +56,6 @@ describe("Get Bookings spec", () => { }); it("Get Booking by Checkin", () => { - cy.wait(1000); bookings_wrapper .get_booking_by({ checkin: sampleCheckinStr }) .then((response) => { From 7e1c164bff062ec108a98775cf19783ad875e1d1 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 18 Mar 2024 15:53:55 -0700 Subject: [PATCH 08/13] try 6 concurrent instances --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4d05298..3910415 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: # run 3 copies of the current job in parallel - containers: [1, 2, 3] + containers: [1, 2, 3, 4, 5, 6] steps: - name: Checkout uses: actions/checkout@v4 From 238fca82df9bdc61f578f6de31da76136e961275 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 25 Mar 2024 11:46:52 -0700 Subject: [PATCH 09/13] possible test fix --- cypress/e2e/get_bookings.cy.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index e963240..2a1293b 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -6,18 +6,19 @@ describe("Get Bookings spec", () => { const sampleFName = bookings_generator.generate_firstname(); const sampleLName = bookings_generator.generate_lastname(); const sampleCheckin = new Date(); - let sampleCheckinStr = + const sampleCheckinStr = bookings_helpers.convertToBookingDateString(sampleCheckin); const sampleCheckout = new Date(); - let sampleCheckoutStr = + const sampleCheckoutStr = bookings_helpers.convertToBookingDateString(sampleCheckout); + let newbooking; before(() => { - let newbooking = bookings_generator.generate_booking(); + newbooking = bookings_generator.generate_booking(); newbooking.firstname = sampleFName; newbooking.lastname = sampleLName; - newbooking.bookingdates.checkin = sampleCheckinStr; - newbooking.bookingdates.checkout = sampleCheckoutStr; + // newbooking.bookingdates.checkin = sampleCheckinStr; + // newbooking.bookingdates.checkout = sampleCheckoutStr; bookings_wrapper.create_booking(newbooking); }); @@ -57,7 +58,7 @@ describe("Get Bookings spec", () => { it("Get Booking by Checkin", () => { bookings_wrapper - .get_booking_by({ checkin: sampleCheckinStr }) + .get_booking_by({ checkin: newbooking.bookingdates.checkin }) .then((response) => { expect(response.status).to.be.equal(200); expect(response.body).to.have.lengthOf.above(0); @@ -66,7 +67,7 @@ describe("Get Bookings spec", () => { it("Get Booking by Checkout", () => { bookings_wrapper - .get_booking_by({ checkout: sampleCheckoutStr }) + .get_booking_by({ checkout: newbooking.bookingdates.checkout }) .then((response) => { expect(response.status).to.be.equal(200); expect(response.body).to.have.lengthOf.above(0); From 47eae9898158247b994b86e7e705a66fefe81b6a Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 25 Mar 2024 12:06:46 -0700 Subject: [PATCH 10/13] possible test fix take 2 --- cypress/e2e/get_bookings.cy.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index 2a1293b..407fec8 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -6,17 +6,21 @@ describe("Get Bookings spec", () => { const sampleFName = bookings_generator.generate_firstname(); const sampleLName = bookings_generator.generate_lastname(); const sampleCheckin = new Date(); - const sampleCheckinStr = - bookings_helpers.convertToBookingDateString(sampleCheckin); + const sampleCheckinStr = "2025-06-07"; // bookings_helpers.convertToBookingDateString(sampleCheckin); const sampleCheckout = new Date(); - const sampleCheckoutStr = - bookings_helpers.convertToBookingDateString(sampleCheckout); + const sampleCheckoutStr = "2024-06-17"; // bookings_helpers.convertToBookingDateString(sampleCheckout); let newbooking; + let checkinMinus1Str; before(() => { newbooking = bookings_generator.generate_booking(); newbooking.firstname = sampleFName; newbooking.lastname = sampleLName; + let checkinMinus1 = new Date(newbooking.bookingdates.checkin); + checkinMinus1.setDate(checkinMinus1.getDate() - 1); + checkinMinus1Str = + bookings_helpers.convertToBookingDateString(checkinMinus1); + cy.log("checkinMinus1Str: " + checkinMinus1Str); // newbooking.bookingdates.checkin = sampleCheckinStr; // newbooking.bookingdates.checkout = sampleCheckoutStr; bookings_wrapper.create_booking(newbooking); From 150291f6f8439a03ffab68a7c2c8a8cbec81853a Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 25 Mar 2024 12:08:17 -0700 Subject: [PATCH 11/13] possible test fix take 3 --- cypress/e2e/get_bookings.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index 407fec8..747568b 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -62,7 +62,7 @@ describe("Get Bookings spec", () => { it("Get Booking by Checkin", () => { bookings_wrapper - .get_booking_by({ checkin: newbooking.bookingdates.checkin }) + .get_booking_by({ checkin: checkinMinus1Str }) .then((response) => { expect(response.status).to.be.equal(200); expect(response.body).to.have.lengthOf.above(0); From e6d6ea8e4450c68a50fb6bf9e7c0119e2d8408ea Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 25 Mar 2024 12:21:44 -0700 Subject: [PATCH 12/13] cleanup and testing with only 1 instance --- .github/workflows/main.yml | 2 +- cypress/e2e/get_bookings.cy.js | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3910415..00885e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: # run 3 copies of the current job in parallel - containers: [1, 2, 3, 4, 5, 6] + containers: [1] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/cypress/e2e/get_bookings.cy.js b/cypress/e2e/get_bookings.cy.js index 747568b..f4dfd44 100644 --- a/cypress/e2e/get_bookings.cy.js +++ b/cypress/e2e/get_bookings.cy.js @@ -5,24 +5,12 @@ import bookings_helpers from "../utils/bookings_helpers"; describe("Get Bookings spec", () => { const sampleFName = bookings_generator.generate_firstname(); const sampleLName = bookings_generator.generate_lastname(); - const sampleCheckin = new Date(); - const sampleCheckinStr = "2025-06-07"; // bookings_helpers.convertToBookingDateString(sampleCheckin); - const sampleCheckout = new Date(); - const sampleCheckoutStr = "2024-06-17"; // bookings_helpers.convertToBookingDateString(sampleCheckout); let newbooking; - let checkinMinus1Str; before(() => { newbooking = bookings_generator.generate_booking(); newbooking.firstname = sampleFName; newbooking.lastname = sampleLName; - let checkinMinus1 = new Date(newbooking.bookingdates.checkin); - checkinMinus1.setDate(checkinMinus1.getDate() - 1); - checkinMinus1Str = - bookings_helpers.convertToBookingDateString(checkinMinus1); - cy.log("checkinMinus1Str: " + checkinMinus1Str); - // newbooking.bookingdates.checkin = sampleCheckinStr; - // newbooking.bookingdates.checkout = sampleCheckoutStr; bookings_wrapper.create_booking(newbooking); }); @@ -61,6 +49,11 @@ describe("Get Bookings spec", () => { }); it("Get Booking by Checkin", () => { + // workaround for fact that restful booker saves dates off by one + let checkinMinus1 = new Date(newbooking.bookingdates.checkin); + checkinMinus1.setDate(checkinMinus1.getDate() - 1); + let checkinMinus1Str = + bookings_helpers.convertToBookingDateString(checkinMinus1); bookings_wrapper .get_booking_by({ checkin: checkinMinus1Str }) .then((response) => { From c5984dfe6e900c834a5f60f588ab76507d3819c5 Mon Sep 17 00:00:00 2001 From: Demian Godon Date: Mon, 25 Mar 2024 12:26:04 -0700 Subject: [PATCH 13/13] restore to originally planned 3 instances --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00885e4..4d05298 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: # run 3 copies of the current job in parallel - containers: [1] + containers: [1, 2, 3] steps: - name: Checkout uses: actions/checkout@v4