You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Micronaut Backend API with some simple REST resources. Implemented in Groovy. The backend uses a (local) mongoDB. The backend services access this mongoDB with GORM for mongoDB
I have two spock test classes with some simpl tests that send REST requests to that backend. Both test classes inject the MongoDatastore to directly access the DB where needed. For example to pre-fill the DB with test data.
When I run the test classes individually, one at a time, the tests in each class run successfully. But when I run both classes together with gradle test one fails with the following error:
java.lang.IllegalStateException: state should be: open
The stacktrace always leads back to a line of code where the backend access one of my GORM Models, e.g. with a finder method.
@Put("/joinTeam")
@Secured(SecurityRule.IS_ANONYMOUS)
HttpResponsejoinTeam(@Body@ValidJoinTeamRequestreq) {
// Remark: Team.class is one of my GORM @Entity Team team =Team.findByInviteCode(req.inviteCode) // <=== this is where the error is thrown
[...]
}
My assumption would be that Micronaut already closes the connection to the DB via the injected mongoDatastore, while the other test is still running. But that is just a guess.
Adding/Removing @AutoCleanup (or in combination with or without @Shared) does not help
Running from within IntelliJ gives the same effect: Run one test class works. Run both at the same time does not work
Adding packe of Application.class to @MicronautTest annotation (mabe) for better class path scanning does not help: @MicronautTest(application = org.doogie.Application.class)
(Please tell me if I can add any more information to this ticket.)
The text was updated successfully, but these errors were encountered:
Team team = Team.find(Filters.eq("inviteCode", req.inviteCode)).first() // this works
//Team team = Team.findByInviteCode(req.inviteCode) // BUG: throws "Internal Server Error: state should be: open"
So in the end this looks like a Groovy Mongo GORM bug ...
I have a Micronaut Backend API with some simple REST resources. Implemented in Groovy. The backend uses a (local) mongoDB. The backend services access this mongoDB with GORM for mongoDB
I have two spock test classes with some simpl tests that send REST requests to that backend. Both test classes inject the MongoDatastore to directly access the DB where needed. For example to pre-fill the DB with test data.
When I run the test classes individually, one at a time, the tests in each class run successfully. But when I run both classes together with
gradle test
one fails with the following error:First test class: HappyCase.groovy
The second TestClass has the same fields.
Error message
The stacktrace always leads back to a line of code where the backend access one of my GORM Models, e.g. with a finder method.
My assumption would be that Micronaut already closes the connection to the DB via the injected mongoDatastore, while the other test is still running. But that is just a guess.
Environment Information
GitHub Repo
https://github.com/Doogiemuc/liquido-micronaut-groovy
Direct Links:
Things I alreay tried
@Shared
does not help@AutoCleanup
(or in combination with or without@Shared
) does not help@MicronautTest(application = org.doogie.Application.class)
(Please tell me if I can add any more information to this ticket.)
The text was updated successfully, but these errors were encountered: