Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e test passing CI but actually failing #186

Open
mrjones-plip opened this issue Nov 15, 2024 · 2 comments · May be fixed by #187
Open

e2e test passing CI but actually failing #186

mrjones-plip opened this issue Nov 15, 2024 · 2 comments · May be fixed by #187
Assignees
Labels
Type: Technical issue Improve something that users won't notice

Comments

@mrjones-plip
Copy link
Contributor

mrjones-plip commented Nov 15, 2024

Describe the issue
On the main branch, when we run the waitForDbt(client) it should succeed, but it fails with an error (see below). Further, CI actually succeeds instead of noticing that there was an error.

   Main workflow Test Suite
Importing docs
Waiting for DBT
    1) "before all" hook in "Main workflow Test Suite"


  0 passing (35s)
  1 failing

  1) Main workflow Test Suite
       "before all" hook in "Main workflow Test Suite":
     Error: DBT models missing records after 30s
      at waitForDbt (file:///home/runner/work/cht-sync/cht-sync/tests/e2e-test.spec.js:33:11)
      at waitForDbt (file:///home/runner/work/cht-sync/cht-sync/tests/e2e-test.spec.js:47:10)
      at async Context.<anonymous> (file:///home/runner/work/cht-sync/cht-sync/tests/e2e-test.spec.js:58:5)

Describe the improvement you'd like
We should fail the CI test if it fails in CI. We should also fix the test so it succeeds (and so does CI then).

Describe alternatives you've considered
NA

@mrjones-plip mrjones-plip added the Type: Technical issue Improve something that users won't notice label Nov 15, 2024
@mrjones-plip mrjones-plip changed the title e2e test actually failing but still passing CI e2e test passing CI but actually failing Nov 15, 2024
@mrjones-plip
Copy link
Contributor Author

mrjones-plip commented Nov 15, 2024

Digging into the docker logs, I see this error in postgres:

2024-11-15 20:26:46.197 UTC [42] STATEMENT:  SELECT * FROM dbt.reports                                 │
2024-11-15 20:26:47.199 UTC [42] ERROR:  relation "dbt.reports" does not exist at character 15 

That's coming from this query:

const dbtReports = await pgClient.query(`SELECT * FROM ${pgSchema}.reports`);

So pgSchema is set to dbt, but the actual schema is called v1. If I change the schema name to v1 in the environments file for both postgres and for dbt :

POSTGRES_SCHEMA="v1"
DBT_POSTGRES_SCHEMA="v1"

If these can't be different, maybe there should only be one variable, not two?

Then all but 2 tests pass:

 Container cht-sync-postgres-1  Starting                                                                                                                                                                                                      
 Container cht-sync-postgres-1  Started                                                                                                                                                                                                       
      ✔ should handle PostgreSQL downtime gracefully (27103ms)                                                                                                                                                                                
    Incremental sync                                                                                                                                                                                                                          
      ✔ should process document edits (18283ms)                                                                                                                                                                                               
      1) should process contact deletes                                                                                                                                                                                                       
      ✔ should process person deletes (18050ms)                                                                                                                                                                                               
      2) should process report deletes                                                                                                                                                                                                        
      ✔ should process incremental inserts (18034ms)                                                                                                                                                                                          
    Conflict resolution                                                                                                                                                                                                                       
Failed to edit document with id 00172650-a2d1-540b-b308-d53ff75f102c: Document update conflict.                                                                                                                                               
      ✔ should handle update conflicts (19065ms)                                                                                                                                                                                              
Failed to delete document with id 00172650-a2d1-540b-b308-d53ff75f102c: Document update conflict.                                                                                                                                             
      ✔ should handle delete conflicts (19056ms)                                                                                                                                                                                              
                                                                                                                                                                                                                                              
  14 passing (3m)                                                                                                                                             
  2 failing                                                                                                                                                   
                                                                                                                                                              
  1) Main workflow Test Suite                                                                                                                                 
       Incremental sync                                                                                                                                       
         should process contact deletes:                                                                                                                      
                                                                                                                                                              
      AssertionError: expected 1 to equal +0                                                                                                                  
      + expected - actual                                                                                                                                     
                                                                                                                                                              
      -1                                                                                                                                                      
      +0                                                                                                                                                      
                                                                                                                                                              
      at Proxy.assertEqual (node_modules/chai/lib/chai/core/assertions.js:1038:12)                                                                           
      at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)                                                                           
      at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)                                                            
      at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)                                                                    
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)                                                           
      at Proxy.<anonymous> (node_modules/chai-exclude/chai-exclude.js:122:21)                                                                                 
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)                                                           
      at Context.<anonymous> (file:///home/mrjones/Documents/MedicMobile/cht-sync/tests/e2e-test.spec.js:217:49)                                              
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)                                                                           
                                                                                                                                                              
  2) Main workflow Test Suite                                                                                                                                 
       Incremental sync                
         should process report deletes:                                        
                                       
      AssertionError: expected 1 to equal +0                                   
      + expected - actual
                                       
      -1                                                                       
      +0                                                                       
                                                                               
      at Proxy.assertEqual (node_modules/chai/lib/chai/core/assertions.js:1038:12)                                                                            
      at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)                                                                            
      at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)                                                             
      at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)                                                                     
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)                                                           
      at Proxy.<anonymous> (node_modules/chai-exclude/chai-exclude.js:122:21)                                                                                 
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)                                                           
      at Context.<anonymous> (file:///home/mrjones/Documents/MedicMobile/cht-sync/tests/e2e-test.spec.js:245:48)                                              
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)   

@mrjones-plip
Copy link
Contributor Author

mrjones-plip commented Nov 16, 2024

I noticed that we don't return false and instead have a throw new Error() in the waitForDbt() call. Elsewhere we use the a return and console.error(), for example in the ``postgres-utils.js` file.

Maybe this difference is causing the test to not error out on GH CI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Technical issue Improve something that users won't notice
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants