use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.
the class AppBundleTest method testAppBundles.
@Test
public void testAppBundles() throws Exception {
String namespace = "App.NS_" + (int) (Math.random() * 10000.0);
String name = "AppBundleTest" + System.currentTimeMillis();
final String appName = namespace + "::" + name;
File bundle = createBundle(namespace, name);
Instance instance = getInstance();
Result<Job, JsonObject> result = instance.submitJob(bundle, null);
verifyJob(result, appName, null);
String jobName = "ABJN_" + (int) (Math.random() * 10000.0) + "_" + System.currentTimeMillis();
JobConfig jc = new JobConfig();
jc.setJobName(jobName);
JsonObject overlay = new JsonObject();
overlay.add("jobConfig", new Gson().toJsonTree(jc));
JsonArray a = new JsonArray();
a.add(overlay);
JsonObject jco = new JsonObject();
jco.add("jobConfigOverlays", a);
result = instance.submitJob(bundle, jco);
verifyJob(result, appName, jobName);
final ApplicationBundle appBundle = instance.uploadBundle(bundle);
assertNotNull(appBundle);
verifyJob(appBundle.submitJob(null), appName, null);
jobName = "ABJN2_" + (int) (Math.random() * 10000.0) + "_" + System.currentTimeMillis();
jc.setJobName(jobName);
overlay.add("jobConfig", new Gson().toJsonTree(jc));
verifyJob(appBundle.submitJob(jco), appName, jobName);
}
use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.
the class AppBundleTest method verifyJob.
private void verifyJob(Result<Job, JsonObject> result, String appName, String jobName) throws Exception {
assertTrue(result.isOk());
assertNotNull(result.getId());
Job job = result.getElement();
assertEquals(result.getId(), job.getId());
// Verify we can call it.
job.refresh();
assertEquals(appName, job.getApplicationName());
if (jobName != null)
assertEquals(jobName, job.getName());
job.cancel();
}
use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.
the class RESTTesterRuntime method start.
@Override
public void start(Object info) throws Exception {
JsonObject deployment = (JsonObject) info;
JsonObject submission = jobject(deployment, "submissionResults");
requireNonNull(submission);
String jobId = jstring(submission, SubmissionResultsKeys.JOB_ID);
requireNonNull(jobId);
trace.info("Testing topology:" + topology().getNamespace() + "::" + topology().getName() + " JobId:" + jobId);
Job job = instanceSupplier.apply(deployment).call().getJob(jobId);
metricsChecker.setup(job);
}
use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.
the class ServiceSubmissionAPITest method cancel.
private void cancel(BigInteger jobId) throws Exception {
JsonElement vse;
if (vcapServices.startsWith(File.separator))
vse = new JsonPrimitive(vcapServices);
else
vse = new JsonParser().parse(vcapServices);
StreamingAnalyticsService sas = StreamingAnalyticsService.of(vse, serviceName);
Job job = sas.getInstance().getJob(jobId.toString());
assertNotNull(job);
boolean canceled = job.cancel();
assertTrue(canceled);
}
use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.
the class StreamsConnectionTest method checkResourceAllocation.
private static void checkResourceAllocation(ResourceAllocation ra, boolean app) throws IOException {
if (ra == null)
return;
assertEquals("resourceAllocation", ra.getResourceType());
if (app)
assertTrue(ra.isApplicationResource());
assertNotNull(ra.getSchedulerStatus());
assertNotNull(ra.getStatus());
Instance rai = ra.getInstance();
for (ProcessingElement pe : ra.getPes()) {
assertNotNull(pe);
assertNotNull(pe.getStatus());
}
for (Job job : ra.getJobs()) {
assertNotNull(job);
assertNotNull(job.getStatus());
}
assertSame(rai, ra.getInstance());
Resource r = ra.getResource();
assertNotNull(r.getId());
assertNotNull(r.getDisplayName());
assertNotNull(r.getIpAddress());
assertEquals("resource", r.getResourceType());
for (Metric metric : r.getMetrics()) {
assertTrue((metric.getMetricKind().equals("counter")) || (metric.getMetricKind().equals("gauge")));
assertEquals("system", metric.getMetricType());
assertEquals("metric", metric.getResourceType());
assertNotNull(metric.getName());
assertNotNull(metric.getDescription());
assertTrue(metric.getLastTimeRetrieved() > 0);
}
}
Aggregations