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

Continuous testing can fail after mvn test when run without clean #23078

Closed
famod opened this issue Jan 20, 2022 · 14 comments · Fixed by #23089
Closed

Continuous testing can fail after mvn test when run without clean #23078

famod opened this issue Jan 20, 2022 · 14 comments · Fixed by #23089
Labels
Milestone

Comments

@famod
Copy link
Member

famod commented Jan 20, 2022

Describe the bug

I added a workaround to my project for #22552 which is setting the scope of lombok to test instead of provided via a specific qtest maven profile (that has <defaultGoal>quarkus:test</defaultGoal>).
This works if cont' testing is started on a "clean" state, but if regular testing was run before via mvn test, this workaround does not have any effect anymore.
In other words, I have to run mvn clean quarkus:test (clean!) if mvn test was run before, which is cumbersome and wastes time if you have many classes to generate/compile. It's also easy to forget.

Expected behavior

Cont' testing should re-setup dependencies (if needed) and should not rely on what mvn test has left behind.

Actual behavior

Doesn't re-setup dependencies and reuses what mvn test has left behind, which in this case means failing bedcause of the provided issue.

How to Reproduce?

q_ct-provided-2.zip (note: uses 999-SNAPSHOT)

  • mvn quarkus:test -Dlombok.scope=test (ok)
  • mvn clean test (ok)
  • mvn quarkus:test -Dlombok.scope=test (fails with ClassNotFoundException)
  • mvn clean quarkus:test -Dlombok.scope=test (ok)

PS: This reproducer simply toggles the scope via a property instead of via a profile, but that's not relevant.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.3.Final and current 999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

FWIW, -Dquarkus.bootstrap.effective-model-builder=true doesn't make a difference.

@famod famod added the kind/bug Something isn't working label Jan 20, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 20, 2022

/cc @stuartwdouglas

@famod
Copy link
Member Author

famod commented Jan 20, 2022

/cc @aloubyansky

@famod famod changed the title Continuous testing can fail if run after mvn test when run without clean Continuous testing can fail after mvn test when run without clean Jan 20, 2022
@aloubyansky
Copy link
Member

Haven't yet checked but this could be related to the classpath caching. target/quarkus/bootstrap/test-app-model.dat. Removing only that one could be enough.

@famod
Copy link
Member Author

famod commented Jan 20, 2022

Yes, that's sufficient!

Btw, one could argue that there should be no difference in dependencies between quarkus:test and mvn test and so a reuse is even desired. Yeah, maybe/probably for the vast majority of cases.

@famod
Copy link
Member Author

famod commented Jan 20, 2022

Is that caching using some cache key or is it simply "if the file exists, just reuse it!"?

@stuartwdouglas
Copy link
Member

The issue would be that the caching does not know about the '-Dlombok.scope=test' parameter, so it will cache whatever the first value is.

@famod
Copy link
Member Author

famod commented Jan 21, 2022

FTR, I'm now using this workaround:

        <profile>
            <id>qtest</id>
            <properties>
                <quarkus.test.continuous-testing>enabled</quarkus.test.continuous-testing>
            </properties>
            <build>
                <!-- note: remove-quarkus-cp-cache is a workaround for https://github.com/quarkusio/quarkus/issues/23078
                           (until https://github.com/quarkusio/quarkus/issues/22552 is resolved) -->
                <defaultGoal>clean:clean@remove-quarkus-cp-cache quarkus:test</defaultGoal>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>remove-quarkus-cp-cache</id>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                                <phase>clean</phase>
                                <configuration>
                                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                                    <filesets>
                                        <fileset>
                                            <directory>${project.build.directory}/quarkus/bootstrap</directory>
                                            <followSymlinks>false</followSymlinks>
                                            <useDefaultExcludes>false</useDefaultExcludes>
                                            <includes>
                                                <include>test-app-model.dat</include>
                                            </includes>
                                        </fileset>
                                    </filesets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <!-- workaround for https://github.com/quarkusio/quarkus/issues/22552 (for JavaSourceTest) -->
                <dependency>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok</artifactId>
                    <version>${lombok.version}</version>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
        </profile>

@aloubyansky
Copy link
Member

Looks like -Dlombok.scope=test isn't propagated to quarkus:test. If you change the scope of lombok in the POM to a constant value test, it seems to work.

@aloubyansky
Copy link
Member

Ah, no, it's not propagated to the default mvn test so it records provided.

@aloubyansky
Copy link
Member

No, it is, sorry, ignore me.

@famod
Copy link
Member Author

famod commented Mar 10, 2022

@aloubyansky FYI, I'm still seeing inconsistencies w.r.t. to that cache, so I need to reintroduce that workaround I posted previously: #23078 (comment)
The concrete problem is with this workaround for ArchUnit: #23929
If mvn test (or similar) was run in a module, running mvn quarkus:test -Parchunit-exclude afterwards will not respect that exclusion.
New issue or reopen?

@aloubyansky
Copy link
Member

Is it still about changing the scope for lombok?

@famod
Copy link
Member Author

famod commented Mar 10, 2022

No, this time it's about what I documented as a workaround in #23929, which is an exclusion for ArchUnit (in a profile).
So same same but different. 😉

@aloubyansky
Copy link
Member

I think we need an option to ignore the cache then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants