use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method findServiceInstance_twoSelectOne.
@Test
public void findServiceInstance_twoSelectOne() {
Microservice v1 = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
mockRegisterMicroservice(appId, microserviceName, "2.0.0");
MicroserviceInstance instance = new MicroserviceInstance();
instance.setServiceId(v1.getServiceId());
registryClient.registerMicroserviceInstance(instance);
List<MicroserviceInstance> result = registryClient.findServiceInstance("self", appId, microserviceName, "1.0.0");
Assert.assertThat(result, Matchers.contains(instance));
MicroserviceInstances microserviceInstances = registryClient.findServiceInstances("self", appId, microserviceName, "1.0.0", "0");
List<MicroserviceInstance> results = microserviceInstances.getInstancesResponse().getInstances();
Assert.assertThat(results, Matchers.contains(instance));
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method getMicroserviceId_fixVersion.
@Test
public void getMicroserviceId_fixVersion() {
Microservice v1 = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
mockRegisterMicroservice(appId, microserviceName, "2.0.0");
String serviceId = registryClient.getMicroserviceId(appId, microserviceName, "1.0.0");
Assert.assertEquals(v1.getServiceId(), serviceId);
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method mockRegisterMicroservice.
private Microservice mockRegisterMicroservice(String appId, String name, String version) {
Microservice microservice = new Microservice();
microservice.setAppId(appId);
microservice.setServiceName(name);
microservice.setVersion(version);
String serviceId = registryClient.registerMicroservice(microservice);
microservice.setServiceId(serviceId);
return microservice;
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method testFindServiceInstance.
@Test
public void testFindServiceInstance() {
Microservice microservice = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
MicroserviceInstance instance = new MicroserviceInstance();
instance.setServiceId(microservice.getServiceId());
String instanceId = registryClient.registerMicroserviceInstance(instance);
Assert.assertNotNull(registryClient.findServiceInstance(microservice.getServiceId(), instanceId));
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class MicroserviceRegisterTask method checkSchemaIdSet.
private boolean checkSchemaIdSet() {
Microservice existMicroservice = srClient.getMicroservice(microservice.getServiceId());
if (existMicroservice == null) {
LOGGER.error("Error to get microservice from service center when check schema set");
return false;
}
Set<String> existSchemas = new HashSet<>(existMicroservice.getSchemas());
Set<String> localSchemas = new HashSet<>(microservice.getSchemas());
schemaIdSetMatch = existSchemas.equals(localSchemas);
if (!schemaIdSetMatch) {
LOGGER.error("SchemaIds is different between local and service center. Please change microservice version. " + "id={} appId={}, name={}, version={}, local schemaIds={}, service center schemaIds={}", microservice.getServiceId(), microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), localSchemas, existSchemas);
return true;
}
LOGGER.info("SchemaIds is equals to service center. id={} appId={}, name={}, version={}, schemaIds={}", microservice.getServiceId(), microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), localSchemas);
return true;
}
Aggregations