Search in sources :

Example 41 with ApolloConfig

use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.

the class ConfigControllerIntegrationTest method testQueryPublicGrayConfigWithOverride.

@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-default-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicGrayConfigWithOverride() throws Exception {
    AtomicBoolean stop = new AtomicBoolean();
    periodicSendMessage(executorService, assembleKey(somePublicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace), stop);
    TimeUnit.MILLISECONDS.sleep(500);
    stop.set(true);
    ResponseEntity<ApolloConfig> response = restTemplate.getForEntity("http://{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class, getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, someClientIp);
    ApolloConfig result = response.getBody();
    assertEquals(HttpStatus.OK, response.getStatusCode());
    assertEquals("TEST-RELEASE-KEY5" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-GRAY-RELEASE-KEY2", result.getReleaseKey());
    assertEquals("override-v1", result.getConfigurations().get("k1"));
    assertEquals("gray-v2", result.getConfigurations().get("k2"));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ApolloConfig(com.ctrip.framework.apollo.core.dto.ApolloConfig) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 42 with ApolloConfig

use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.

the class ConfigControllerIntegrationTest method testQueryPublicConfigWithDataCenterNotFoundAndOverride.

@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-default-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigWithDataCenterNotFoundAndOverride() throws Exception {
    String someDCNotFound = "someDCNotFound";
    ResponseEntity<ApolloConfig> response = restTemplate.getForEntity("http://{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}", ApolloConfig.class, getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, someDCNotFound);
    ApolloConfig result = response.getBody();
    assertEquals("TEST-RELEASE-KEY5" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-RELEASE-KEY3", result.getReleaseKey());
    assertEquals(someAppId, result.getAppId());
    assertEquals(someDefaultCluster, result.getCluster());
    assertEquals(somePublicNamespace, result.getNamespaceName());
    assertEquals("override-v1", result.getConfigurations().get("k1"));
    assertEquals("default-v2", result.getConfigurations().get("k2"));
}
Also used : ApolloConfig(com.ctrip.framework.apollo.core.dto.ApolloConfig) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 43 with ApolloConfig

use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.

the class ConfigControllerIntegrationTest method testQueryPublicGrayConfigWithIncorrectCaseAndOverride.

@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-default-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicGrayConfigWithIncorrectCaseAndOverride() throws Exception {
    AtomicBoolean stop = new AtomicBoolean();
    periodicSendMessage(executorService, assembleKey(somePublicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace), stop);
    TimeUnit.MILLISECONDS.sleep(500);
    stop.set(true);
    ResponseEntity<ApolloConfig> response = restTemplate.getForEntity("http://{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class, getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), someClientIp);
    ApolloConfig result = response.getBody();
    assertEquals(HttpStatus.OK, response.getStatusCode());
    assertEquals("TEST-RELEASE-KEY5" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-GRAY-RELEASE-KEY2", result.getReleaseKey());
    assertEquals("override-v1", result.getConfigurations().get("k1"));
    assertEquals("gray-v2", result.getConfigurations().get("k2"));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ApolloConfig(com.ctrip.framework.apollo.core.dto.ApolloConfig) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 44 with ApolloConfig

use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.

the class ConfigControllerIntegrationTest method testQueryPublicConfigWithDataCenterNotFoundAndNoOverride.

@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigWithDataCenterNotFoundAndNoOverride() throws Exception {
    String someDCNotFound = "someDCNotFound";
    ResponseEntity<ApolloConfig> response = restTemplate.getForEntity("http://{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}", ApolloConfig.class, getHostUrl(), someAppId, someCluster, somePublicNamespace, someDCNotFound);
    ApolloConfig result = response.getBody();
    assertEquals("TEST-RELEASE-KEY3", result.getReleaseKey());
    assertEquals(someAppId, result.getAppId());
    assertEquals(someCluster, result.getCluster());
    assertEquals(somePublicNamespace, result.getNamespaceName());
    assertEquals("default-v1", result.getConfigurations().get("k1"));
    assertEquals("default-v2", result.getConfigurations().get("k2"));
}
Also used : ApolloConfig(com.ctrip.framework.apollo.core.dto.ApolloConfig) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 45 with ApolloConfig

use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.

the class ConfigControllerIntegrationTest method testQueryConfigWithDefaultClusterAndDefaultNamespaceOK.

@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryConfigWithDefaultClusterAndDefaultNamespaceOK() throws Exception {
    ResponseEntity<ApolloConfig> response = restTemplate.getForEntity("http://{baseurl}/configs/{appId}/{clusterName}/{namespace}", ApolloConfig.class, getHostUrl(), someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, ConfigConsts.NAMESPACE_APPLICATION);
    ApolloConfig result = response.getBody();
    assertEquals(HttpStatus.OK, response.getStatusCode());
    assertEquals("TEST-RELEASE-KEY1", result.getReleaseKey());
    assertEquals("v1", result.getConfigurations().get("k1"));
}
Also used : ApolloConfig(com.ctrip.framework.apollo.core.dto.ApolloConfig) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

ApolloConfig (com.ctrip.framework.apollo.core.dto.ApolloConfig)57 Test (org.junit.Test)49 Sql (org.springframework.test.context.jdbc.Sql)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)11 BaseIntegrationTest (com.ctrip.framework.apollo.BaseIntegrationTest)10 Config (com.ctrip.framework.apollo.Config)10 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)10 Properties (java.util.Properties)8 OrderedProperties (com.ctrip.framework.apollo.util.OrderedProperties)7 AppNamespace (com.ctrip.framework.apollo.common.entity.AppNamespace)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 ConfigChangeListener (com.ctrip.framework.apollo.ConfigChangeListener)4 ApolloConfigNotification (com.ctrip.framework.apollo.core.dto.ApolloConfigNotification)4 ConfigChangeEvent (com.ctrip.framework.apollo.model.ConfigChangeEvent)4 Map (java.util.Map)4 ApolloNotificationMessages (com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages)3 HttpRequest (com.ctrip.framework.apollo.util.http.HttpRequest)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3