use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class ByteStreamTest method readLargeWrite.
@Test(timeout = 30000)
public void readLargeWrite() throws IOException {
String scope = "ByteStreamTest";
String stream = "readLargeWrite";
StreamConfiguration config = StreamConfiguration.builder().build();
@Cleanup StreamManager streamManager = new StreamManagerImpl(PRAVEGA.getLocalController(), Mockito.mock(ConnectionPool.class));
// create a scope
Boolean createScopeStatus = streamManager.createScope(scope);
log.info("Create scope status {}", createScopeStatus);
// create a stream
Boolean createStreamStatus = streamManager.createStream(scope, stream, config);
log.info("Create stream status {}", createStreamStatus);
@Cleanup ByteStreamClientFactory client = createClientFactory(scope);
byte[] payload = new byte[2 * PendingEvent.MAX_WRITE_SIZE + 2];
Arrays.fill(payload, (byte) 7);
byte[] readBuffer = new byte[PendingEvent.MAX_WRITE_SIZE];
Arrays.fill(readBuffer, (byte) 0);
@Cleanup ByteStreamWriter writer = client.createByteStreamWriter(stream);
@Cleanup ByteStreamReader reader = client.createByteStreamReader(stream);
writer.write(payload);
writer.closeAndSeal();
assertEquals(PendingEvent.MAX_WRITE_SIZE, StreamHelpers.readAll(reader, readBuffer, 0, readBuffer.length));
assertEquals(7, readBuffer[readBuffer.length - 1]);
Arrays.fill(readBuffer, (byte) 0);
assertEquals(PendingEvent.MAX_WRITE_SIZE, StreamHelpers.readAll(reader, readBuffer, 0, readBuffer.length));
assertEquals(7, readBuffer[readBuffer.length - 1]);
Arrays.fill(readBuffer, (byte) 0);
assertEquals(2, reader.read(readBuffer));
assertEquals(7, readBuffer[0]);
assertEquals(7, readBuffer[1]);
assertEquals(0, readBuffer[2]);
assertEquals(-1, reader.read(readBuffer));
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class AuthEnabledInProcPravegaClusterTest method testCreateStreamFailsWithInvalidClientConfig.
/**
* This test verifies that create stream fails when the client config is invalid.
*
* Note: The timeout being used for the test is kept rather large so that there is ample time for the expected
* exception to be raised even in case of abnormal delays in test environments.
*/
@Test(timeout = 50000)
public void testCreateStreamFailsWithInvalidClientConfig() {
ClientConfig clientConfig = ClientConfig.builder().credentials(new DefaultCredentials("", "")).controllerURI(URI.create(EMULATOR.pravega.getInProcPravegaCluster().getControllerURI())).build();
@Cleanup StreamManager streamManager = StreamManager.create(clientConfig);
AssertExtensions.assertThrows("Auth exception did not occur.", () -> streamManager.createScope(scope), e -> hasAuthExceptionAsRootCause(e));
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class TlsEnabledInProcPravegaClusterTest method testCreateStreamFailsWithInvalidClientConfig.
/**
* This test verifies that create stream fails when the client config is invalid.
*
* Note: The timeout being used for the test is kept rather large so that there is ample time for the expected
* exception to be raised even in case of abnormal delays in test environments.
*/
@Test(timeout = 50000)
public void testCreateStreamFailsWithInvalidClientConfig() {
// Truststore for the TLS connection is missing.
ClientConfig clientConfig = ClientConfig.builder().controllerURI(URI.create(EMULATOR.pravega.getInProcPravegaCluster().getControllerURI())).build();
ControllerImplConfig controllerImplConfig = ControllerImplConfig.builder().clientConfig(clientConfig).retryAttempts(1).initialBackoffMillis(1000).backoffMultiple(1).maxBackoffMillis(1000).build();
@Cleanup StreamManager streamManager = new StreamManagerImpl(clientConfig, controllerImplConfig);
AssertExtensions.assertThrows("TLS exception did not occur.", () -> streamManager.createScope(scope), e -> hasTlsException(e));
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class ControllerServiceStarterTest method testStartStop.
@Test(timeout = 30000)
public void testStartStop() throws URISyntaxException {
Assert.assertNotNull(storeClient);
@Cleanup ControllerServiceStarter starter = new ControllerServiceStarter(createControllerServiceConfig(), storeClient, SegmentHelperMock.getSegmentHelperMockForTables(executor));
starter.startAsync();
starter.awaitRunning();
// Now, that starter has started, perform some rpc operations.
URI uri = new URI((enableAuth ? "tls" : "tcp") + "://localhost:" + grpcPort);
final String testScope = "testScope";
StreamManager streamManager = new StreamManagerImpl(ClientConfig.builder().controllerURI(uri).credentials(new DefaultCredentials(SecurityConfigDefaults.AUTH_ADMIN_PASSWORD, SecurityConfigDefaults.AUTH_ADMIN_USERNAME)).trustStore(SecurityConfigDefaults.TLS_CA_CERT_PATH).build());
streamManager.createScope(testScope);
streamManager.deleteScope(testScope);
streamManager.close();
starter.stopAsync();
starter.awaitTerminated();
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class ControllerGrpcListStreamsTest method createStreams.
private void createStreams(ClientConfig clientConfig, String scopeName, List<String> streamNames) {
@Cleanup StreamManager streamManager = StreamManager.create(clientConfig);
assertNotNull(streamManager);
boolean isScopeCreated = streamManager.createScope(scopeName);
assertTrue("Failed to create scope", isScopeCreated);
streamNames.forEach(s -> {
boolean isStreamCreated = streamManager.createStream(scopeName, s, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
if (!isStreamCreated) {
throw new RuntimeException("Failed to create stream: " + s);
}
});
}
Aggregations