use of co.cask.cdap.proto.id.ServiceId in project cdap by caskdata.
the class CLIMainTest method testService.
@Test
public void testService() throws Exception {
ServiceId service = FAKE_APP_ID.service(PrefixedEchoHandler.NAME);
ServiceId serviceV1 = FAKE_APP_ID_V_1.service(PrefixedEchoHandler.NAME);
String serviceName = String.format("%s.%s", FakeApp.NAME, PrefixedEchoHandler.NAME);
String serviceArgument = String.format("%s version %s", serviceName, ApplicationId.DEFAULT_VERSION);
String serviceV1Argument = String.format("%s version %s", serviceName, V1_SNAPSHOT);
try {
// Test service commands with no optional version argument
testCommandOutputContains(cli, "start service " + serviceName, "Successfully started service");
testCommandOutputContains(cli, "get endpoints service " + serviceName, "POST");
testCommandOutputContains(cli, "get endpoints service " + serviceName, "/echo");
testCommandOutputContains(cli, "check service availability " + serviceName, "Service is available");
testCommandOutputContains(cli, "call service " + serviceName + " POST /echo body \"testBody\"", ":testBody");
testCommandOutputContains(cli, "stop service " + serviceName, "Successfully stopped service");
assertProgramStatus(programClient, service, "STOPPED");
// Test service commands with version argument when two versions of the service are running
testCommandOutputContains(cli, "start service " + serviceArgument, "Successfully started service");
testCommandOutputContains(cli, "start service " + serviceV1Argument, "Successfully started service");
assertProgramStatus(programClient, service, "RUNNING");
assertProgramStatus(programClient, serviceV1, "RUNNING");
testCommandOutputContains(cli, "get endpoints service " + serviceArgument, "POST");
testCommandOutputContains(cli, "get endpoints service " + serviceV1Argument, "POST");
testCommandOutputContains(cli, "get endpoints service " + serviceArgument, "/echo");
testCommandOutputContains(cli, "get endpoints service " + serviceV1Argument, "/echo");
testCommandOutputContains(cli, "check service availability " + serviceArgument, "Service is available");
testCommandOutputContains(cli, "check service availability " + serviceV1Argument, "Service is available");
testCommandOutputContains(cli, "call service " + serviceArgument + " POST /echo body \"testBody\"", ":testBody");
testCommandOutputContains(cli, "call service " + serviceV1Argument + " POST /echo body \"testBody\"", ":testBody");
} finally {
// Stop all running services
programClient.stopAll(NamespaceId.DEFAULT);
}
}
use of co.cask.cdap.proto.id.ServiceId in project cdap by caskdata.
the class SetRouteConfigCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE));
String routeConfig = arguments.get(ArgumentName.ROUTE_CONFIG.getName());
serviceClient.storeRouteConfig(serviceId, ArgumentParser.parseStringIntegerMap(routeConfig, ArgumentName.ROUTE_CONFIG.toString()));
output.printf("Successfully set route configuration of %s '%s' of application '%s' to '%s'\n", ElementType.SERVICE.getName(), serviceId.getProgram(), serviceId.getApplication(), routeConfig);
}
Aggregations