Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Fix MergedContextConfiguration cache key for runtime contexts #1262

Closed

Description

@snicoll

While #1242 prevents certain ContextCustomizerFactory implementations from running again at runtime and lets us support more test use cases in a native image, it has the side effect of not providing the same key for the created MergedContextConfiguration as some of these implementations have an impact on the key.

We already know at build time which tests corresponds to which "context" as given by the created mapping:

public class TestContextBootstrapInitializer {
  public static Map<String, Supplier<SmartContextLoader>> getContextLoaders() {
    Map<String, Supplier<SmartContextLoader>> entries = new HashMap<>();
    entries.put("org.springframework.samples.petclinic.owner.PetControllerTests", () -> new SpringBootAotContextLoader(PetControllerTestsContextInitializer.class, WebApplicationType.REACTIVE, SpringBootTest.WebEnvironment.NONE));
    entries.put("org.springframework.samples.petclinic.PetclinicIntegrationTests", () -> new SpringBootAotContextLoader(PetclinicIntegrationTestsContextInitializer.class, WebApplicationType.SERVLET, SpringBootTest.WebEnvironment.MOCK));
    entries.put("org.springframework.samples.petclinic.owner.OwnerControllerTests", () -> new SpringBootAotContextLoader(OwnerControllerTestsContextInitializer.class, WebApplicationType.REACTIVE, SpringBootTest.WebEnvironment.NONE));
    entries.put("org.springframework.samples.petclinic.vet.VetControllerTests", () -> new SpringBootAotContextLoader(VetControllerTestsContextInitializer.class, WebApplicationType.REACTIVE, SpringBootTest.WebEnvironment.NONE));
    entries.put("org.springframework.samples.petclinic.owner.VisitControllerTests", () -> new SpringBootAotContextLoader(VisitControllerTestsContextInitializer.class, WebApplicationType.REACTIVE, SpringBootTest.WebEnvironment.NONE));
    return entries;
  }
}

This mapping shows that all tests have an isolated context. On the other hand, the following mapping shows that the two tests share the same context:

public class TestContextBootstrapInitializer {
  public static Map<String, Supplier<SmartContextLoader>> getContextLoaders() {
    Map<String, Supplier<SmartContextLoader>> entries = new HashMap<>();
    entries.put("com.example.sampleactuator.repository.SpeakerRepositoryTests", () -> new SpringBootAotContextLoader(TestContextBootstrapInitializer0.class));
    entries.put("com.example.sampleactuator.repository.SpeakerRepositoryAnotherTests", () -> new SpringBootAotContextLoader(TestContextBootstrapInitializer0.class));
    return entries;
  }
}

We should research a way to surface this information and update AotCacheAwareContextLoaderDelegate to use this mechanism to cache the contexts.

Activity

  1. added this to the 0.11.0-RC1 milestone on Nov 15, 2021
  2. sbrannen commented on Nov 18, 2021

    @sbrannen
    Contributor

    Update

    I'm making progress on this, but I do not foresee completing this in time for RC1.

  3. modified the milestones: 0.11.0-RC1, 0.11.0 on Nov 18, 2021
  4. sbrannen commented on Nov 18, 2021

    @sbrannen
    Contributor

    Current work on this issue can be viewed in the following feature branch.

    main...sbrannen:issues/gh-1262-AOT-MergedContextConfiguration

  5. snicoll commented on Dec 7, 2021

    @snicoll
    ContributorAuthor

    Closing in favor of PR #1341

  6. added
    status: superseded
    on Dec 7, 2021
  7. removed this from the 0.11.0 milestone on Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: supersededtype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions