Uploaded image for project: 'mod-invoice'
  1. mod-invoice
  2. MODINVOICE-265

Unit tests can fail because of async operations

    XMLWordPrintable

    Details

    • Type: Tech Debt
    • Status: Open (View Workflow)
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Template:
    • Development Team:
      Thunderjet

      Description

      Overview:

      ApiTestBase$verifyPostResponse has been using verifyInvoiceSummaryUpdateEvent to wait for some update events to finish. As this is no longer done async, verifyInvoiceSummaryUpdateEvent is not longer needed. But without a new sleep to replace it, tests can fail because some async operations happen at the same time as the next tests (verifyInvoiceSummaryUpdateEvent had a minimum 50ms delay which was helping to avoid issues).
      The sleep workaround introduced in the resolution for MODINVOICE-233 is not ideal because the right value depends on the environment, and it slows down the tests.

       

      Steps to reproduce:
      (errors may vary depending on the running environment)

      • Remove the sleep in ApiTestBase$verifyPostResponse
      • mvn test
        [...]
        16:28:08 [] [] [] [] INFO BatchVoucherExportsApiTest === Test Put Batch voucher export === 16:28:08 [] [] [] [] INFO ApiTestBase Using mock datafile: mockdata/batchVoucherExports/566c9156-e52f-4597-9fee-5ddac91d14f2.json 16:28:08 [] [] [] [] INFO MockServer id: null 16:28:08 [] [] [] [] INFO ApiTestBase Using mock datafile: mockdata/batchVouchers/null.json 16:28:08 [] [] [] [] ERROR HelperUtils Exception calling GET /batch-voucher-storage/batch-vouchers/null?lang=en java.util.concurrent.CompletionException: org.folio.invoices.rest.exceptions.HttpException: null
        [...]
        [INFO] Results:
        [INFO] 
        [ERROR] Failures: 
        [ERROR] ApiTestSuite$BatchVoucherExportsApiTestNested>BatchVoucherExportsApiTest.testUpdateBatchVoucherExport:130 
        Expected: is "Updated message"
         but: was "Batch voucher was not found"
        [INFO] 
        [ERROR] Tests run: 384, Failures: 1, Errors: 0, Skipped: 4

      Resolution

      • A better workaround to wait for async operations to finish without using a fixed sleep value, OR
      • Change the tests to support parallel execution (this could be complicated and probably require changes in MockServer)

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                damieng Damien Guillaume
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:

                    TestRail: Runs

                      TestRail: Cases