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

after creating app without database, tests are not working #76

Closed
sgulci opened this issue Sep 2, 2020 · 8 comments · Fixed by #122
Closed

after creating app without database, tests are not working #76

sgulci opened this issue Sep 2, 2020 · 8 comments · Fixed by #122
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@sgulci
Copy link

sgulci commented Sep 2, 2020

After creating Quarkus application without a database and cache layer, tests are not working because liqubase config file is not presented

Just run below
mvn test

and the logs here :

[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.mycompany.myapp.web.rest.UserJWTControllerTest
[INFO] H2 database started in TCP server mode; server status: TCP server running at tcp://127.0.1.1:9092 (only local connections)
2020-09-02 11:43:15,081 INFO  [io.agr.pool] (main) Datasource '<default>': Initial size smaller than min. Connections will be created when necessary
2020-09-02 11:43:15,244 ERROR [io.qua.application] (main) Failed to start application: java.lang.IllegalStateException: liquibase.exception.ChangeLogParseException: config/liquibase/master.xml does not exist
        at io.quarkus.liquibase.runtime.LiquibaseRecorder.doStartActions(LiquibaseRecorder.java:89)
        at io.quarkus.deployment.steps.LiquibaseProcessor$configureRuntimeProperties41.deploy_0(LiquibaseProcessor$configureRuntimeProperties41.zig:98)
        at io.quarkus.deployment.steps.LiquibaseProcessor$configureRuntimeProperties41.deploy(LiquibaseProcessor$configureRuntimeProperties41.zig:36)
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:179)
        at io.quarkus.runtime.Application.start(Application.java:89)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:177)
        at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:151)
        at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:278)
        at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:301)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:359)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:189)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
        at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
        at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:127)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
        at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
Caused by: liquibase.exception.ChangeLogParseException: config/liquibase/master.xml does not exist
        at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:106)
        at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:15)
        at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217)
        at liquibase.Liquibase.validate(Liquibase.java:1559)
        at io.quarkus.liquibase.runtime.LiquibaseRecorder.validate(LiquibaseRecorder.java:131)
        at io.quarkus.liquibase.runtime.LiquibaseRecorder.doStartActions(LiquibaseRecorder.java:73)
        ... 49 more

[INFO] H2 database was shut down; server status: Not started
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 2, Time elapsed: 6.777 s <<< FAILURE! - in com.mycompany.myapp.web.rest.UserJWTControllerTest
[ERROR] com.mycompany.myapp.web.rest.UserJWTControllerTest.testAuthorizeFails  Time elapsed: 0.011 s  <<< ERROR!
java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
Caused by: java.lang.RuntimeException: Failed to start quarkus
Caused by: java.lang.IllegalStateException: liquibase.exception.ChangeLogParseException: config/liquibase/master.xml does not exist
Caused by: liquibase.exception.ChangeLogParseException: config/liquibase/master.xml does not exist
@danielpetisme
Copy link
Member

danielpetisme commented Sep 7, 2020

Indeed, the tests rely on liquibase regardless of the database configuration.
Would definitively make sense to add a guard to prevent data migration related files to be produced.
For instance here
https://github.com/jhipster/jhipster-quarkus/blob/master/generators/server/templates/quarkus/src/test/java/package/web/rest/UserResourceTest.java.ejs#L93
adding

<%_ if (databaseType === 'sql') { _%>
   @BeforeEach
    public void databaseFixture() {
        try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {
            liquibase.dropAll();
            liquibase.validate();
            liquibase.update(liquibaseFactory.createContexts(), liquibaseFactory.createLabels());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
<%_ }%>

Would do the job.

Fancy a PR?

@sgulci
Copy link
Author

sgulci commented Sep 10, 2020

will do at the weekend

@joewhite101 joewhite101 added this to the v1.0.0 milestone Sep 12, 2020
@joewhite101 joewhite101 added the bug Something isn't working label Sep 12, 2020
@joewhite101
Copy link
Contributor

Hey @sgulci were you able to get to this? If not maybe we can pick it up in the JHipster code day tomorrow. LMK.

@sgulci
Copy link
Author

sgulci commented Sep 12, 2020

Ohh then you can pickup for jhipster code

@joewhite101 joewhite101 added the good first issue Good for newcomers label Sep 12, 2020
@nshaw nshaw self-assigned this Sep 14, 2020
@nshaw
Copy link

nshaw commented Sep 14, 2020

I made a start on this but could use another pair of eyes on it. This branch eliminates the liquibase errors but I still see 3 skipped tests once it's complete so I don't know if that's acceptable: https://github.com/nshaw/jhipster-quarkus/tree/76-no-db-tests-fail.

@avdev4j
Copy link
Contributor

avdev4j commented Nov 25, 2020

hi,
I think the problem is more complex than that. I've checked your branch @nshaw but I thinks should include the data partial file. At the same time we have to add conditions on entities and User to not have @entity or any related code to Hibernate or JPA.

tests are failing because all the code related to databases are still presents and it tries to connect to a db that does not exists.

@nshaw
Copy link

nshaw commented Nov 25, 2020

@avdev4j feel free to start from scratch if you have time to dig into this. I'm afraid I made a first attempt and then never made it back to it.

@avdev4j
Copy link
Contributor

avdev4j commented Nov 26, 2020

Hi @nshaw don't worry I'm working on it. Basically, an important part of the generated code will be removed when selected no db.

Pleas take a look of #122

Have a good day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants