Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-8040

BootstrappingFunctionIntegrationTest unintentionally creates a full Cache stack

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • tests
    • None

    Description

      BootstrappingFunctionIntegrationTest unintentionally creates a full Cache stack. I have renamed and moved BootstrappingFunctionTest from src/test to src/integrationTest because it creates a full Cache/DistributedSystem and leaves the SocketCreatorFactory in an initialized state which causes other unit tests such as SocketCreatorFactoryJUnitTest to fail:

      org.apache.geode.internal.net.SocketCreatorFactoryJUnitTest > testNewSSLConfigSSLComponentLocator FAILED
          java.lang.AssertionError
              at org.junit.Assert.fail(Assert.java:86)
              at org.junit.Assert.assertTrue(Assert.java:41)
              at org.junit.Assert.assertTrue(Assert.java:52)
              at org.apache.geode.internal.net.SocketCreatorFactoryJUnitTest.testNewSSLConfigSSLComponentLocator(SocketCreatorFactoryJUnitTest.java:106)
      

      The cause is improper syntax in the test for partial mocking a Spy. This when/thenReturn:

      when(bootstrappingFunction.verifyCacheExists()).thenReturn(mockCache);
      

      ...first invokes the actual verifyCacheExists() method which creates a real Cache and then returns mockCache. This should instead be:

      doReturn(mockCache).when(bootstrappingFunction).verifyCacheExists();
      

      Unfortunately, the class BootstrappingFunction requires additional changes to make it unit testable. The next test failure after fixing the Mockito syntax is:

      org.apache.geode.cache.CacheClosedException: A cache has not yet been created.
      
      	at org.apache.geode.internal.cache.CacheFactoryStatics.getAnyInstance(CacheFactoryStatics.java:87)
      	at org.apache.geode.modules.util.CreateRegionFunction.<init>(CreateRegionFunction.java:59)
      	at org.apache.geode.modules.util.BootstrappingFunction.registerFunctions(BootstrappingFunction.java:124)
      	at org.apache.geode.modules.util.BootstrappingFunction.execute(BootstrappingFunction.java:67)
      	at org.apache.geode.modules.util.BootstrappingFunctionIntegrationTest.registerFunctionGetsCalledOnNonLocators(BootstrappingFunctionIntegrationTest.java:101)
      

      When I make the changes necessary to make BootstrappingFunction unit testable, the tomcat session backwards compatibility tests all start failing in UpgradeTest:

      org.apache.geode.session.tests.TomcatSessionBackwardsCompatibilityTomcat8WithOldModuleCanDoPutsTest > test[0] FAILED
          java.lang.RuntimeException: Something very bad happened when trying to start container TOMCAT8_client-server_test0_0_6b9ba51c-9690-47aa-8e56-8e5b6cb22af4_<unknown>
              at org.apache.geode.session.tests.ContainerManager.startContainer(ContainerManager.java:80)
              at org.apache.geode.session.tests.ContainerManager.startContainers(ContainerManager.java:91)
              at org.apache.geode.session.tests.ContainerManager.startAllInactiveContainers(ContainerManager.java:98)
              at org.apache.geode.session.tests.TomcatSessionBackwardsCompatibilityTestBase.doPutAndGetSessionOnAllClients(TomcatSessionBackwardsCompatibilityTestBase.java:187)
              at org.apache.geode.session.tests.TomcatSessionBackwardsCompatibilityTomcat8WithOldModuleCanDoPutsTest.test(TomcatSessionBackwardsCompatibilityTomcat8WithOldModuleCanDoPutsTest.java:35)
      
              Caused by:
              java.lang.RuntimeException: Something very bad happened to this container when starting. Check the cargo_logs folder for container logs.
                  at org.apache.geode.session.tests.ServerContainer.start(ServerContainer.java:218)
                  at org.apache.geode.session.tests.ContainerManager.startContainer(ContainerManager.java:77)
                  ... 4 more
      
                  Caused by:
                  org.codehaus.cargo.container.ContainerException: Deployable [http://localhost:22942/cargocpc/index.html] failed to finish deploying within the timeout period [120000]. The Deployable state is thus unknown.
                      at org.codehaus.cargo.container.spi.deployer.DeployerWatchdog.watch(DeployerWatchdog.java:111)
                      at org.codehaus.cargo.container.spi.AbstractLocalContainer.waitForCompletion(AbstractLocalContainer.java:385)
                      at org.codehaus.cargo.container.spi.AbstractLocalContainer.start(AbstractLocalContainer.java:232)
                      at org.apache.geode.session.tests.ServerContainer.start(ServerContainer.java:216)
      

      Attachments

        Issue Links

          Activity

            People

              klund Kirk Lund
              klund Kirk Lund
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: