Search in sources :

Example 16 with Instance

use of com.ibm.streamsx.rest.Instance in project streamsx.topology by IBMStreams.

the class StreamsOnlyConnectionTest method testGetInstances.

@Test
public void testGetInstances() throws Exception {
    assumeNotNull(System.getenv("STREAMS_REST_URL"));
    StreamsConnection connection = StreamsConnection.createInstance(null, null, null);
    connection.allowInsecureHosts(true);
    // get all instances in the domain
    List<Instance> instances = connection.getInstances();
    // there should be at least one instance
    assertTrue(instances.size() > 0);
    Instance i2;
    String instanceName = System.getenv("STREAMS_INSTANCE_ID");
    if (instanceName != null) {
        i2 = connection.getInstance(instanceName);
        assertEquals(instanceName, i2.getId());
        i2.refresh();
        assertEquals(instanceName, i2.getId());
    } else {
        i2 = instances.get(0);
    }
    List<ProcessingElement> instancePes = i2.getPes();
    for (ProcessingElement pe : instancePes) {
        assertNotNull(pe);
    }
    for (Instance instance : instances) StreamsConnectionTest.checkDomainFromInstance(instance);
    try {
        // try a fake instance name
        connection.getInstance("fakeName");
        fail("the connection.getInstance call should have thrown an exception");
    } catch (RESTException r) {
        // not a failure, this is the expected result
        assertEquals(r.toString(), 404, r.getStatusCode());
    }
}
Also used : ProcessingElement(com.ibm.streamsx.rest.ProcessingElement) RESTException(com.ibm.streamsx.rest.RESTException) Instance(com.ibm.streamsx.rest.Instance) StreamsConnection(com.ibm.streamsx.rest.StreamsConnection) Test(org.junit.Test)

Aggregations

Instance (com.ibm.streamsx.rest.Instance)16 Test (org.junit.Test)6 StreamsConnection (com.ibm.streamsx.rest.StreamsConnection)5 JsonObject (com.google.gson.JsonObject)4 Job (com.ibm.streamsx.rest.Job)4 StreamingAnalyticsService (com.ibm.streamsx.rest.StreamingAnalyticsService)4 Metric (com.ibm.streamsx.rest.Metric)3 ProcessingElement (com.ibm.streamsx.rest.ProcessingElement)3 JobConfig (com.ibm.streamsx.topology.jobconfig.JobConfig)3 JsonParser (com.google.gson.JsonParser)2 InputPort (com.ibm.streamsx.rest.InputPort)2 Operator (com.ibm.streamsx.rest.Operator)2 OutputPort (com.ibm.streamsx.rest.OutputPort)2 RESTException (com.ibm.streamsx.rest.RESTException)2 ICP4DAuthenticator (com.ibm.streamsx.rest.internal.ICP4DAuthenticator)2 StandaloneAuthenticator (com.ibm.streamsx.rest.internal.StandaloneAuthenticator)2 IOException (java.io.IOException)2 Executor (org.apache.http.client.fluent.Executor)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1