-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix #18465 and upgrade other junit4 tests to junit5 in mustache files #18470
Conversation
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
thanks for the PR. i did a test with java (apache-httpclient) with petstore spec but got the following errors:
can you please take a look when you've time?
|
Alright... I've fixed it, but I'm afraid this has become hell of a commit. Yesterday I forgot about the pom templates, so I started upgrading the dependencies to junit5 there. But then I also upgraded the complete project to junit5 (at least I think so). I've generated the petstore with both, the apache-httpclient and the native client. Both seem to be fine now. But there's one problem I couldn't manage to fix:
I guess this change could be the problem:
This should've been the way to migrate a JUnit4 test based on SpringRunner to JUnit5's SpringExtension. Oh, I forgot to remove the old import of |
https://github.com/OpenAPITools/openapi-generator/actions/runs/8816015528/job/24232484564?pr=18470 reported some errors. please take a look when you've time |
at this stage would it be possible to file a PR just to update the java client mustache templates to use junit5? we can get that merge first and then tackle the remaining junit tests one by one. (we prefer smaller PRs for easier review and merge) |
I've made a stupid search&replace yesterday, which replaced way too much. I think now I've fixed it. But there's still a problem in the Scala generator... I know this PR has become huge, but I think it's 98% finished by now. |
I'm afraid I don't know enough Scala to fix this (probably last) issue. When I'd chosen the wrong Scala version in the dependencies I was getting the same errors as ci/circle currently has (compile errors due to missing symbols). But on my local machine compilation works, all dependencies use Scala 2.12. But the tests still fail due to http rc 301:
I can't figure out how to tell Akka's http client to follow the redirect. There's still an open issue for this feature since 2016: akka/akka-http#195 |
@@ -14,10 +14,10 @@ libraryDependencies ++= Seq( | |||
"org.json4s" %% "json4s-jackson" % "3.6.7", | |||
"org.json4s" %% "json4s-ext" % "3.6.7", | |||
"de.heikoseeberger" %% "akka-http-json4s" % "1.27.0", | |||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.4.1", | |||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thorstenhirsch just a wild guess but why did you change the scala-collection-compat
from 2.4.1
to 2.12.0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of these warnings:
[WARNING] Scala library detected 2.12.13 doesn't match scala.compat.version : 2.4.1
[WARNING] Expected all dependencies to require Scala version: 2.4.1
[WARNING] org.openapitools:scala-akka-petstore-client:1.0.0 requires scala version: 2.12.13
[WARNING] Multiple versions of scala libraries detected!
Well, the warnings are still there, but 2.12.0 is closer to 2.12.13, right? ;-)
[WARNING] Scala library detected 2.12.13 doesn't match scala.compat.version : 2.12.0
[WARNING] Expected all dependencies to require Scala version: 2.12.0
[WARNING] org.openapitools:scala-akka-petstore-client:1.0.0 requires scala version: 2.12.13
[WARNING] Multiple versions of scala libraries detected!
Looks like the expectation (2nd line) is always the version of scala-collection-compat, but I can't find a matching version for all components, because...
- with 2.4.1 there's no Scala 2.4.x (anymore?)
- with 2.12.13 there's no scala-collection-compat 2.12.13 (the most recent one is 2.12.0)
- with 2.12.0 there's a new warning popping up:
[WARNING] com.typesafe.akka:akka-actor_2.12:2.6.12 requires scala version: 2.12.11
So I thought with Scala 2.12.13 and scala-collection-compat 2.12.0 the versions differ the least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering why changes to the Scala libraries are necessary as you were only fixing JUnit here which is a Java library? So I would try to avoid touching anything else?
So with Scala 2.13 the petstore test compiles, but the test fails. First it failed, because http://petstore.swagger.io redirects to https and the test doesn't follow redirects. And when the test makes use of https directly it fails, because the server blocks https connections from CircleCI? I have no idea why all these problems only arise now after migrating to junit5. |
@thorstenhirsch thanks again for the PR. as this PR now changes 1300+ files, which is not easy to review (the file diff page is taking a long time to load). what about filing separate PRs for each generator/library (e.g. resteasy, resttemplate) as smaller PRs will get merged easier and quicker? |
migrate all templates, all samples, and the project itself (including archunit) upgrade all maven-surefire-plugin 2.x versions to 2.22.2 and remove deprecated forkMode setting
…ngRunner to SpringExtension
61e9aed
to
e08095e
Compare
@wing328 Now I finally understand why changing samples directly doesn't make sense. May I suggest to add something like the following sentence to the contributing guide in the section #code-generators?
|
I think that is basically in the "PR checklist" but probably can't hurt to repeat 😅. Thank you for all the hard work @thorstenhirsch ! |
While #18465 is only about the native client, I've also upgrade JUnit4 to JUnit5 in all other *.mustache files. I'm not sure which api_tests should generate disabled tests, but I couldn't figure out a pattern, and when temporarily activating a disabled test it threw an error, so I decided to keep disabled/enabled tests as they were.
mvn clean test
runs successful on my employer's Windows 10 machine, but I wouldn't completely trust./bin/generate-samples.sh ./bin/configs/*.yaml
and./bin/utils/export_docs_generators.sh
on this machine, so please check that again in your environment.Also I don't know what to do about "update samples", so I marked this point with a question mark. Please tell me if I have further todos.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)