Skip to content

Upgrade to SpringBoot 2.6.1, updating unit test and code accordingly - #284

Merged
mr-c merged 14 commits into
mainfrom
spring_boot_upgrade
Dec 18, 2021
Merged

mr-c merged 14 commits into
mainfrom
spring_boot_upgrade

Conversation

@mr-c

@mr-c mr-c commented Nov 5, 2020 •

Copy link
Copy Markdown
Member

(redo of #280 )

The reported issue is related to the following case:

https://stackoverflow.com/questions/49316751/spring-data-jpa-findone-change-to-optional-how-to-use-this

Solution:

[Editing Pom.xml]

update Spring Boot:

org.springframework.boot spring-boot-starter-parent 2.2.2.RELEASE

add the following dependency for ensuring that we use the appropriate spring-data-commons version.

org.springframework.data spring-data-commons 2.0.1.RELEASE

[WorkflowService.java]

Replace any occurrence of the findOne with findById(id).orElse(null) here:

org.commonwl.view.workflow.WorkflowRepository
org.commonwl.view.workflow.QueuedWorkflowRepository

With these changes we should expect to build successfully.

  • upgrade to Spring Boot 2.6.1 (latest)
  • upgrade to JUnit 5 (comes with Spring Boot, unless we enable the JUnit 4 integration layer)
  • Add a javax.validation implementation
  • Upgrade spring-data-commons to 2.6.0
  • Fix unit tests
  • Upgrade Jena
  • Manual testing to confirm everything works
  • Fix GH Actions build

@mr-c

mr-c commented Nov 5, 2020

Copy link
Copy Markdown
Member Author

Error creating bean with name 'mongoConfig': Unsatisfied dependency expressed through field 'mongoMappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.mapping.context.AbstractMappingContext.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V

https://travis-ci.com/github/common-workflow-language/cwlviewer/builds/198507618#L1273

@mr-c

mr-c commented Dec 16, 2021

Copy link
Copy Markdown
Member Author

@kinow I assigned you this PR, but feel free to make a new branch

@kinow
kinow force-pushed the spring_boot_upgrade branch from 59d8d70 to 9a28792 Compare December 16, 2021 10:24
@kinow

kinow commented Dec 16, 2021

Copy link
Copy Markdown
Member

Rebased.

Comment thread pom.xml
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like javax.validation implementation is not included, so had to import the Hibernate validator (this is not ORM, just the validation part, which is a reference implementation of JSR-303)

@kinow

kinow commented Dec 17, 2021 •

Copy link
Copy Markdown
Member

(checklist moved to first comment, so it is visible on the issues page)

@mr-c

mr-c commented Dec 17, 2021

Copy link
Copy Markdown
Member Author

Thanks @kinow ! I moved your checklist to the first comment so that it shows up on the issues browser. Let me know if you don't have the permissions to edit it further.

@kinow

kinow commented Dec 17, 2021

Copy link
Copy Markdown
Member

Thanks @kinow ! I moved your checklist to the first comment so that it shows up on the issues browser. Let me know if you don't have the permissions to edit it further.

That'll be easier to update and for others to see too. Thanks @mr-c !

@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

Huh, funny, mvnw test failed on GH Actions, but passing locally. Will upgrade the remaining libraries, have a look at miniwdl + types, and revisit this PR later (to give my 🧠 a break 😄 )

@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

Manual tests passed with docker-compose up --build. Unit tests passing locally. Last part now, fix test in GH Actions, then it should be ready for review! 🎉

@kinow
kinow force-pushed the spring_boot_upgrade branch from bc9ca67 to 187aa81 Compare December 18, 2021 05:58
@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

All right. The MongoDB test passed locally, because the tests were run sequentially. On GitHub Actions they were running in parallel, so there was a conflict with ports. Setting the port number to 0 makes SpringData/MongoDB to allocate a random port 👍

@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

@mr-c this PR should upgrade SpringBoot to 2.6.1, the latest release. The API changed a little from 1.5.x to 2.x, and also to 2.6.1. Removed some deprecated code, and fixed settings and Java annotations so that all tests would pass. Tested with the docker-compose.yml file, after replacing image by the commented build.

I don't know enough about the production environment to say it will work flawlessly when merged & deployed. So, if possible, a backup when upgrading would be recommended IMO.

Let me know if you know what would be the next steps here, or if I need to talk with someone else to see it merged & deployed 🎉

-Bruno

@mr-c

mr-c commented Dec 18, 2021

Copy link
Copy Markdown
Member Author

@kinow this is fantastic! Deployment is manual, so no worries about merging this PR. Do you want me to squash this down to one commit, or do you want to cleanup these commits and then I'll rebase onto the primary branch?

@kinow
kinow force-pushed the spring_boot_upgrade branch from 187aa81 to 0b9f326 Compare December 18, 2021 07:54
Comment thread pom.xml Resolved
@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

@kinow this is fantastic! Deployment is manual, so no worries about merging this PR. Do you want me to squash this down to one commit, or do you want to cleanup these commits and then I'll rebase onto the primary branch?

Forgot about squashing commits. Done now 🙂 Thanks!

@mr-c

mr-c commented Dec 18, 2021

Copy link
Copy Markdown
Member Author

Oh, I can always easily squash down to one commit myself in the web interface. I wondered if you preferred one big commit or a series of fewer commits with cleaned up descriptions.

@mr-c
mr-c force-pushed the spring_boot_upgrade branch from 0b9f326 to b0ebf68 Compare December 18, 2021 09:38
@mr-c
mr-c enabled auto-merge (rebase) December 18, 2021 09:38
@mr-c
mr-c disabled auto-merge December 18, 2021 09:39
@mr-c

mr-c commented Dec 18, 2021

Copy link
Copy Markdown
Member Author

@kinow I force pushed with correct attribution. You wrote a lot of nice commit messages, and some of them should be saved. But since I didn't have a local checkout prior to your squash I can't regroup your original commits. Would you mind doing so? (next week is fine!)

I did make a local backup of view.commonwl.org via the instructions at https://github.com/common-workflow-language/cwlviewer#dumprestore and I did a partial restore until I got bored. Seems fine!

@kinow
kinow force-pushed the spring_boot_upgrade branch 2 times, most recently from 1b8a573 to a75d12c Compare December 18, 2021 10:36
Had to add a new dependency for the embedded MongoDB server used for tests.

The version of MongoDB used for tests (embedded) also needs to be defined now. And
MongoDB/SpringData integration appears to be more strict. A query like
{ obj.property: ?0 } failed, and took me a long time to recognize that it was missing
quotes, so { 'obj.property': ?0 } fixed it.

Finally, there was also an issue with serialization. For some reason now the Mongo
repository was failing to serialize a response for Workflow. The object contained a
final String that was used for the base URL of permanent links, and Mongo/Spring/etc
wanted a way to set that value in the constructor. Tried the @PersistenceConstructor
annotation but that didn't work. In the end it was easy to fix it by making the
final String now a constant
@kinow
kinow force-pushed the spring_boot_upgrade branch from a75d12c to 23574bf Compare December 18, 2021 10:41
@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

@kinow I force pushed with correct attribution.

Did I replace an author somewhere, or forgot a commit? I thought perhaps you meant the co-author bit that appears after I rebase; but I don't know how to remove it. Hopefully I didn't mess it up now...

You wrote a lot of nice commit messages, and some of them should be saved. But since I didn't have a local checkout prior to your squash I can't regroup your original commits. Would you mind doing so? (next week is fine!)

Thanks! I remember adding some links in the commits to explain where settings/changes were coming from. But there are two commits fixing unit tests which could be combined perhaps. The commit message could be merged into a single message with links & notes.

Feel free to re-organize the commits if you'd like @mr-c. I used git reflog to reset to before my rebase, and cherry-pick your commits. I hope I didn't miss anything.

I did make a local backup of view.commonwl.org via the instructions at https://github.com/common-workflow-language/cwlviewer#dumprestore and I did a partial restore until I got bored. Seems fine!

Hooray! 🎉

Thanks!

@mr-c

mr-c commented Dec 18, 2021

Copy link
Copy Markdown
Member Author

@kinow I force pushed with correct attribution.

Did I replace an author somewhere, or forgot a commit? I thought perhaps you meant the co-author bit that appears after I rebase; but I don't know how to remove it.

No, the issue was your commit didn't list you as an author! :-)

Hopefully I didn't mess it up now...
Everything looks good, thanks!

Feel free to re-organize the commits if you'd like @mr-c. I used git reflog to reset to before my rebase, and cherry-pick your commits. I hope I didn't miss anything.

I did a local check and all is good; thanks! I'll do some light commit combining with git rebase -i and I'll force push

@mr-c
mr-c force-pushed the spring_boot_upgrade branch from 23574bf to 7bfe840 Compare December 18, 2021 10:58
@mr-c mr-c changed the title Restart spring boot upgrade Upgrade to SpringBoot 2.6.1, updating unit test and code accordingly Dec 18, 2021
@mr-c
mr-c enabled auto-merge (rebase) December 18, 2021 10:59
@mr-c
mr-c merged commit 9444d7e into main Dec 18, 2021
@mr-c
mr-c deleted the spring_boot_upgrade branch December 18, 2021 11:07
@kinow

kinow commented Dec 18, 2021

Copy link
Copy Markdown
Member

No, the issue was your commit didn't list you as an author! :-)

🤣 ops!

Thanks @mr-c !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants