TAMULib / mod-camunda

Apache License 2.0
0 stars 0 forks source link

TLS escapes isolation under Linux so add a Static Mock to constrain the TLS use case. #250

Closed kaladay closed 2 months ago

kaladay commented 2 months ago

On Linux I get:

WorkflowControllerAdviceTest.exceptionsThrownForActivateWorkflowTest(Exception, String, int)[1] » IllegalState Failed to load ApplicationContext for [WebMergedContextConfiguration@2e79cc2e testClass = org.folio.rest.camunda.controller.advice.WorkflowControllerAdviceTest, locations = [], classes = [org.folio.rest.camunda.SpringOkapiModule], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [[ImportsContextCustomizer@2d4d2d55 key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@54e18a46, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@666b91db, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3c87b7ef, org.springframework.boot.test.web.reactive.server.WebTestClientContextCustomizer@6e71c9dc, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@4b3fa0b3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@7097d921, org.springframework.boot.test.context.SpringBootTestAnnotation@8061ab26], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]

That test is not touched in this branch and so this is some sort of isolation problem.

Investigation shows that it happens under Linux but not Windows. The Thread Local Storage (TLS) appears to be the culprit.

Add a static mock wrapper around the TLS use case to prevent the escaping of test isolation.