Search in sources :

Example 6 with Service

use of io.pravega.test.system.framework.services.Service in project pravega by pravega.

the class PravegaTest method createStream.

/**
 * Invoke the createStream method, ensure we are able to create stream.
 *
 * @throws InterruptedException if interrupted
 * @throws URISyntaxException   If URI is invalid
 * @throws ExecutionException   if error in create stream
 */
@Before
public void createStream() throws InterruptedException, ExecutionException {
    Service conService = Utils.createPravegaControllerService(null);
    List<URI> ctlURIs = conService.getServiceDetails();
    URI controllerUri = ctlURIs.get(0);
    log.info("Invoking create stream with Controller URI: {}", controllerUri);
    @Cleanup ConnectionFactory connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
    ControllerImpl controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(controllerUri).build()).build(), connectionFactory.getInternalExecutor());
    assertTrue(controller.createScope(STREAM_SCOPE).get());
    assertTrue(controller.createStream(config).get());
}
Also used : ConnectionFactory(io.pravega.client.netty.impl.ConnectionFactory) ControllerImpl(io.pravega.client.stream.impl.ControllerImpl) Service(io.pravega.test.system.framework.services.Service) URI(java.net.URI) Cleanup(lombok.Cleanup) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) Before(org.junit.Before)

Example 7 with Service

use of io.pravega.test.system.framework.services.Service in project pravega by pravega.

the class StreamCutsTest method setup.

@Before
public void setup() {
    Service conService = Utils.createPravegaControllerService(null);
    List<URI> ctlURIs = conService.getServiceDetails();
    controllerURI = ctlURIs.get(0);
    final ClientConfig clientConfig = Utils.buildClientConfig(controllerURI);
    controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(clientConfig).maxBackoffMillis(5000).build(), executor);
    streamManager = StreamManager.create(clientConfig);
    assertTrue("Creating scope", streamManager.createScope(SCOPE));
    assertTrue("Creating stream one", streamManager.createStream(SCOPE, STREAM_ONE, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(RG_PARALLELISM_ONE)).build()));
    assertTrue("Creating stream two", streamManager.createStream(SCOPE, STREAM_TWO, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(RG_PARALLELISM_TWO)).build()));
}
Also used : ControllerImpl(io.pravega.client.control.impl.ControllerImpl) Service(io.pravega.test.system.framework.services.Service) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ClientConfig(io.pravega.client.ClientConfig) URI(java.net.URI) Before(org.junit.Before)

Example 8 with Service

use of io.pravega.test.system.framework.services.Service in project pravega by pravega.

the class ZookeeperTest method zkTest.

/**
 * Invoke the zookeeper test, ensure zookeeper can be accessed.
 * The test fails in case zookeeper cannot be accessed.
 */
@Test
public void zkTest() {
    log.info("Start execution of ZkTest");
    Service zk = Utils.createZookeeperService();
    URI zkUri = zk.getServiceDetails().get(0);
    CuratorFramework curatorFrameworkClient = CuratorFrameworkFactory.newClient(zkUri.getHost() + ":2181", new RetryOneTime(5000));
    curatorFrameworkClient.start();
    log.info("CuratorFramework status {} ", curatorFrameworkClient.getState());
    assertEquals("Connection to zk client ", STARTED, curatorFrameworkClient.getState());
    log.info("Zookeeper Service URI : {} ", zkUri);
    log.info("ZkTest  execution completed");
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) Service(io.pravega.test.system.framework.services.Service) URI(java.net.URI) Test(org.junit.Test)

Example 9 with Service

use of io.pravega.test.system.framework.services.Service in project pravega by pravega.

the class AbstractScaleTests method createControllerURI.

private URI createControllerURI() {
    Service conService = Utils.createPravegaControllerService(null);
    List<URI> ctlURIs = conService.getServiceDetails();
    return ctlURIs.get(0);
}
Also used : Service(io.pravega.test.system.framework.services.Service) URI(java.net.URI)

Example 10 with Service

use of io.pravega.test.system.framework.services.Service in project pravega by pravega.

the class DynamicRestApiTest method listScopes.

@Test
public void listScopes() {
    Service controllerService = Utils.createPravegaControllerService(null);
    List<URI> controllerURIs = controllerService.getServiceDetails();
    URI controllerGRPCUri = controllerURIs.get(0);
    URI controllerRESTUri = controllerURIs.get(1);
    Invocation.Builder builder;
    String protocol = Utils.TLS_AND_AUTH_ENABLED ? "https://" : "http://";
    restServerURI = protocol + controllerRESTUri.getHost() + ":" + controllerRESTUri.getPort();
    log.info("REST Server URI: {}", restServerURI);
    // Validate the liveliness of the server through a 'ping' request.
    resourceURl = new StringBuilder(restServerURI).append("/ping").toString();
    webTarget = client.target(resourceURl);
    builder = webTarget.request();
    @Cleanup Response response = builder.get();
    assertEquals(String.format("Received unexpected status code: %s in response to 'ping' request.", response.getStatus()), OK.getStatusCode(), response.getStatus());
    final String scope1 = RandomStringUtils.randomAlphanumeric(10);
    final String stream1 = RandomStringUtils.randomAlphanumeric(10);
    String responseAsString = null;
    ClientConfig clientConfig = Utils.buildClientConfig(controllerGRPCUri);
    // Create a scope.
    @Cleanup StreamManager streamManager = StreamManager.create(clientConfig);
    assertNotNull(streamManager);
    boolean isScopeCreated = streamManager.createScope(scope1);
    assertTrue("Failed to create scope", isScopeCreated);
    // Create a stream.
    boolean isStreamCreated = streamManager.createStream(scope1, stream1, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    assertTrue("Failed to create stream", isStreamCreated);
    // Validate that the scope is returned from the request.
    webTarget = client.target(restServerURI).path("v1").path("scopes");
    builder = webTarget.request();
    response = builder.get();
    assertEquals("Get scopes failed.", OK.getStatusCode(), response.getStatus());
    responseAsString = response.readEntity(String.class);
    assertTrue(responseAsString.contains(String.format("\"scopeName\":\"%s\"", scope1)));
    // Validate that the stream is returned from the request.
    webTarget = client.target(restServerURI).path("v1").path("scopes").path(scope1).path("streams");
    builder = webTarget.request();
    response = builder.get();
    assertEquals("Get streams failed.", OK.getStatusCode(), response.getStatus());
    responseAsString = response.readEntity(String.class);
    assertTrue(responseAsString.contains(String.format("\"streamName\":\"%s\"", stream1)));
}
Also used : Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) StreamManager(io.pravega.client.admin.StreamManager) Service(io.pravega.test.system.framework.services.Service) ClientConfig(io.pravega.client.ClientConfig) URI(java.net.URI) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Aggregations

Service (io.pravega.test.system.framework.services.Service)48 URI (java.net.URI)41 Before (org.junit.Before)18 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)16 ControllerImpl (io.pravega.client.control.impl.ControllerImpl)12 Environment (io.pravega.test.system.framework.Environment)12 ClientConfig (io.pravega.client.ClientConfig)10 StreamManagerImpl (io.pravega.client.admin.impl.StreamManagerImpl)8 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)8 Test (org.junit.Test)8 ExecutionException (java.util.concurrent.ExecutionException)7 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)6 Cleanup (lombok.Cleanup)5 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)3 PravegaControllerService (io.pravega.test.system.framework.services.marathon.PravegaControllerService)3 EventStreamClientFactory (io.pravega.client.EventStreamClientFactory)2 StreamManager (io.pravega.client.admin.StreamManager)2 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)2 ControllerImpl (io.pravega.client.stream.impl.ControllerImpl)2 Invocation (javax.ws.rs.client.Invocation)2