OHDSI / WebAPI

OHDSI WebAPI contains all OHDSI services that can be called from OHDSI applications
Apache License 2.0
126 stars 156 forks source link

Fix: reinstate tests #2368

Closed pieterlukasse closed 2 weeks ago

pieterlukasse commented 2 months ago

Reinstate tests, rolling back what was done in https://github.com/OHDSI/WebAPI/pull/1903

As far as I can see, there are just 4 same tests (out of 220) that always fail:

[INFO] Results:
[INFO] 
Error:  Failures: 
Error:    CohortCharacterizationServiceTest.testExportGeneration:105->doTestExportGeneration:132->checkRequest:151 Checking dataitem org.ohdsi.webapi.cohortcharacterization.CohortCharacterizationServiceTest$ParamItem@130c39d9[analysisIds=[107],cohortIds=[2],isSummary=false,isComparative=false] expected:<1> but was:<0>
Error:    CohortCharacterizationServiceTest.testExportGenerationWithStrata:110->doTestExportGeneration:132->checkRequest:151 Checking dataitem org.ohdsi.webapi.cohortcharacterization.CohortCharacterizationServiceTest$ParamItem@747b18e5[analysisIds=[107],cohortIds=[2],isSummary=false,isComparative=false] expected:<1> but was:<0>
Error:    PermissionTest.permsTest:85->AbstractDatabaseTest.loadPrepData:112 Exception processing table name='public.sec_role'
Error:    PermissionTest.wildcardTest:101->AbstractDatabaseTest.loadPrepData:112 Exception processing table name='public.sec_role'
[INFO] 
Error:  Tests run: 220, Failures: 4, Errors: 0, Skipped: 0

I would advocate for only skipping these 4 for now instead of skipping all 220.

chrisknoll commented 1 month ago

Hmm, the last 2 about permission and wildcard tests were things I recently added which leverages the embedded db_unit test framework...i'm wondering why it doesn't work across a full test but I'm sure it ran on the individual ones (even both those together as I ran the entire test class).

I can pull down this branch and try to run the entire suite in debug and see if there's something that is a side-effect of the other tests that interfere with running this one test

pieterlukasse commented 1 month ago

Thanks @chrisknoll . I'm looking at the CohortCharacterizationServiceTest ones (the fist two). So perhaps we can fix all 4 together 👍

pieterlukasse commented 1 month ago

@chrisknoll the tests you mentioned seem to fail only at the DELETE step:

loadPrepData(testDataSetsPaths, DatabaseOperation.DELETE);
chrisknoll commented 1 month ago

@chrisknoll the tests you mentioned seem to fail only at the DELETE step:

loadPrepData(testDataSetsPaths, DatabaseOperation.DELETE);

Thanks, I'm on a bit of a crunch and haven't' been able to dig in. But the DatabaseOperation.DELETE is where it's suppsoed to take the test data that is in the prep data set and delete any row that matches the data in there (effectively removing the rows that were inserted at the start of the test). I'll have to run through it by hand to trace through what part of it is failing the delete...is it a FK delete order problem? not sure yet....but I'm sure I can figure it out.

pieterlukasse commented 1 month ago

is it a FK delete order problem?

It seems to fail at public.sec_role:

Exception processing table name='public.sec_role'
pieterlukasse commented 1 month ago

@chrisknoll should I just disable the two PermissionTest ones as well for now and log a separate ticket so they can get fixed later?

pieterlukasse commented 1 month ago

StudyInfoTest also started failing (side effect?), so I disabled that as well:

Error:  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.101 s <<< FAILURE! - in org.ohdsi.webapi.test.feasibility.StudyInfoTest
Error:  testStudyCRUD(org.ohdsi.webapi.test.feasibility.StudyInfoTest)  Time elapsed: 0.068 s  <<< ERROR!
javax.persistence.EntityNotFoundException: Unable to find org.ohdsi.webapi.source.Source with id 1
    at org.ohdsi.webapi.test.feasibility.StudyInfoTest.testStudyCRUD(StudyInfoTest.java:63)

Summary: 5 unit tests have been disabled. The rest seems to be passing now ✅ :

[INFO] Results:
[INFO] 
Warning:  Tests run: 220, Failures: 0, Errors: 0, Skipped: 5

⚠️ Integration Tests (IT) seem to still be failing though 🤔 :

[INFO] Results:
[INFO] 
Error:  Errors: 
Error:    SecurityIT.testServiceSecurity » AmbiguousTableName COHORT
[INFO] 
Error:  Tests run: 6, Failures: 0, Errors: 1, Skipped: 1

The SecurityIT tests also reports a lot of errors like

2024-05-30T12:22:48.9955376Z 2024-05-30 12:22:48.970 INFO main org.ohdsi.webapi.test.SecurityIT - [] - failed service PUT:http://localhost:34829/WebAPI/reusable/0/version/0
2024-05-30T12:22:48.9957527Z 2024-05-30 12:22:48.971 INFO main org.ohdsi.webapi.test.SecurityIT - [] - testing service DELETE:http://localhost:34829/WebAPI/reusable/0/version/0
2024-05-30T12:22:48.9959824Z 2024-05-30 12:22:48.993 ERROR http-nio-auto-1-exec-4 org.ohdsi.webapi.util.GenericExceptionMapper - [] - javax.ws.rs.NotFoundException: There is no reusable version with id = 0.

or

2024-05-30T12:22:51.5852794Z 2024-05-30 12:22:51.580 INFO main org.ohdsi.webapi.test.SecurityIT - [] - tested service PUT:http://localhost:34829/WebAPI/conceptset/0 with code 500
2024-05-30T12:22:51.5853793Z 2024-05-30 12:22:51.580 INFO main org.ohdsi.webapi.test.SecurityIT - [] - failed service PUT:http://localhost:34829/WebAPI/conceptset/0
2024-05-30T12:22:51.5857909Z 2024-05-30 12:22:51.580 INFO main org.ohdsi.webapi.test.SecurityIT - [] - testing service PUT:http://localhost:34829/WebAPI/estimation/0
2024-05-30T12:22:51.5928720Z 2024-05-30 12:22:51.591 ERROR http-nio-auto-1-exec-7 org.ohdsi.webapi.util.GenericExceptionMapper - [] - java.lang.NullPointerException

Somehow the IT tests step finished with SUCCESS, so the errors are not being detected correctly. To be solved in a separate ticket, together with the disabled tests above perhaps.

pieterlukasse commented 1 month ago

@chrisknoll here are the follow-up tickets: