use of org.apache.servicecomb.registry.consumer.MicroserviceVersionRule in project java-chassis by ServiceComb.
the class TestConsumers method delete_disconnect_cache.
@Test
public void delete_disconnect_cache() {
MicroserviceVersionRule microserviceVersionRule = appManager.getOrCreateMicroserviceVersionRule(appId, serviceName, versionRule);
Assert.assertEquals("0.0.0.0+", microserviceVersionRule.getVersionRule().getVersionRule());
Assert.assertEquals(1, microserviceManager.getVersionsByName().size());
mockDisconnect();
appManager.pullInstances();
Assert.assertEquals(1, microserviceManager.getVersionsByName().size());
}
use of org.apache.servicecomb.registry.consumer.MicroserviceVersionRule in project java-chassis by ServiceComb.
the class TestConsumers method testCreateRuleServiceNotExists.
@Test
public void testCreateRuleServiceNotExists() {
serviceName = "notExist";
MicroserviceVersions microserviceVersions = microserviceManager.getOrCreateMicroserviceVersions(serviceName);
MicroserviceVersionRule microserviceVersionRule = microserviceVersions.getOrCreateMicroserviceVersionRule(versionRule);
Assert.assertEquals("0.0.0.0+", microserviceVersionRule.getVersionRule().getVersionRule());
Assert.assertNull(microserviceVersionRule.getLatestMicroserviceVersion());
Assert.assertEquals(0, microserviceManager.getVersionsByName().size());
}
use of org.apache.servicecomb.registry.consumer.MicroserviceVersionRule in project java-chassis by ServiceComb.
the class TestConsumers method watchDeleteEvent.
@Test
public void watchDeleteEvent() {
MicroserviceVersionRule microserviceVersionRule = appManager.getOrCreateMicroserviceVersionRule(appId, serviceName, versionRule);
Assert.assertEquals("0.0.0.0+", microserviceVersionRule.getVersionRule().getVersionRule());
Assert.assertEquals(1, microserviceManager.getVersionsByName().size());
mockNotExist();
MicroserviceKey key = new MicroserviceKey();
MicroserviceInstanceChangedEvent event = new MicroserviceInstanceChangedEvent();
event.setKey(key);
key.setAppId(appId);
key.setServiceName(serviceName);
eventBus.post(event);
Assert.assertEquals(0, microserviceManager.getVersionsByName().size());
}
use of org.apache.servicecomb.registry.consumer.MicroserviceVersionRule in project java-chassis by ServiceComb.
the class ITUtils method waitMicroserviceReady.
public static Map<String, MicroserviceInstance> waitMicroserviceReady(String appId, String microserviceName, String strVersionRule, int minInstanceCount) {
LOGGER.info("waiting for microservice online. appId={}, name={}, minInstanceCount={}", appId, microserviceName, minInstanceCount);
Map<String, MicroserviceInstance> instances;
for (; ; ) {
MicroserviceVersionRule microserviceVersionRule = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceVersionRule(appId, microserviceName, strVersionRule);
instances = microserviceVersionRule.getInstances();
if (instances.size() >= minInstanceCount) {
break;
}
LOGGER.info("waiting for microservice online. appId={}, name={}, expect minInstanceCount={}, real instanceCount={}.", appId, microserviceName, minInstanceCount, instances.size());
// pull at once
DiscoveryManager.INSTANCE.getAppManager().pullInstances();
forceWait(TimeUnit.SECONDS, 1);
}
LOGGER.info("microservice already online. appId={}, name={}, instanceCount={}", appId, microserviceName, minInstanceCount);
return instances;
}
use of org.apache.servicecomb.registry.consumer.MicroserviceVersionRule in project java-chassis by ServiceComb.
the class TestInstanceCacheCheckerWithoutMock method check_StaticMicroservice.
@Test
public void check_StaticMicroservice() {
microserviceName = appId + ":" + microserviceName;
RegistrationManager.INSTANCE.registerMicroserviceMappingByEndpoints(microserviceName, "1", Arrays.asList("rest://localhost:8080"), ThirdPartyServiceForUT.class);
MicroserviceVersionRule microserviceVersionRule = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceVersionRule(appId, microserviceName, DefinitionConst.VERSION_RULE_ALL);
Assert.assertEquals(microserviceName, microserviceVersionRule.getLatestMicroserviceVersion().getMicroserviceName());
InstanceCacheSummary instanceCacheSummary = checker.check();
expectedSummary.setStatus(Status.NORMAL);
Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
}
Aggregations