use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ConfigServiceWithCacheTest method testFindLatestActiveReleaseWithIrrelevantMessages.
@Test
public void testFindLatestActiveReleaseWithIrrelevantMessages() throws Exception {
long someNewNotificationId = someNotificationId + 1;
String someIrrelevantKey = "someIrrelevantKey";
when(releaseMessageService.findLatestReleaseMessageForMessages(Lists.newArrayList(someKey))).thenReturn(someReleaseMessage);
when(releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName)).thenReturn(someRelease);
when(someReleaseMessage.getId()).thenReturn(someNotificationId);
Release release = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
Release stillOldRelease = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
someNotificationMessages.put(someIrrelevantKey, someNewNotificationId);
Release shouldStillBeOldRelease = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
assertEquals(someRelease, release);
assertEquals(someRelease, stillOldRelease);
assertEquals(someRelease, shouldStillBeOldRelease);
verify(releaseMessageService, times(1)).findLatestReleaseMessageForMessages(Lists.newArrayList(someKey));
verify(releaseService, times(1)).findLatestActiveRelease(someAppId, someClusterName, someNamespaceName);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ConfigServiceWithCacheTest method testFindLatestActiveReleaseWithReleaseNotFound.
@Test
public void testFindLatestActiveReleaseWithReleaseNotFound() throws Exception {
when(releaseMessageService.findLatestReleaseMessageForMessages(Lists.newArrayList(someKey))).thenReturn(null);
when(releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName)).thenReturn(null);
Release release = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
Release anotherRelease = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
int retryTimes = 100;
for (int i = 0; i < retryTimes; i++) {
configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
}
assertNull(release);
assertNull(anotherRelease);
verify(releaseMessageService, times(1)).findLatestReleaseMessageForMessages(Lists.newArrayList(someKey));
verify(releaseService, times(1)).findLatestActiveRelease(someAppId, someClusterName, someNamespaceName);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class AbstractBaseIntegrationTest method buildRelease.
public Release buildRelease(String name, String comment, Namespace namespace, Map<String, String> configurations, String owner) {
Release release = new Release();
release.setReleaseKey(ReleaseKeyGenerator.generateReleaseKey(namespace));
release.setDataChangeCreatedTime(new Date());
release.setDataChangeCreatedBy(owner);
release.setDataChangeLastModifiedBy(owner);
release.setName(name);
release.setComment(comment);
release.setAppId(namespace.getAppId());
release.setClusterName(namespace.getClusterName());
release.setNamespaceName(namespace.getNamespaceName());
release.setConfigurations(GSON.toJson(configurations));
release = releaseRepository.save(release);
return release;
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class DefaultConfigServiceTest method testLoadConfigWithGrayRelease.
@Test
public void testLoadConfigWithGrayRelease() throws Exception {
Release grayRelease = mock(Release.class);
long grayReleaseId = 999;
when(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(someClientAppId, someClientIp, someClientLabel, someConfigAppId, someClusterName, defaultNamespaceName)).thenReturn(grayReleaseId);
when(releaseService.findActiveOne(grayReleaseId)).thenReturn(grayRelease);
Release release = configService.loadConfig(someClientAppId, someClientIp, someClientLabel, someConfigAppId, someClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages);
verify(releaseService, times(1)).findActiveOne(grayReleaseId);
verify(releaseService, never()).findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName);
assertEquals(grayRelease, release);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class DefaultConfigServiceTest method testLoadConfigWithReleaseNotFound.
@Test
public void testLoadConfigWithReleaseNotFound() throws Exception {
when(releaseService.findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName)).thenReturn(null);
Release release = configService.loadConfig(someClientAppId, someClientIp, someClientLabel, someConfigAppId, someClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages);
assertNull(release);
}
Aggregations