use of io.pravega.test.system.framework.services.Service in project pravega by pravega.
the class PravegaTest method setup.
/**
* This is used to setup the various services required by the system test framework.
*
* @throws InterruptedException If interrupted
* @throws MarathonException when error in setup
* @throws URISyntaxException If URI is invalid
*/
@Environment
public static void setup() throws MarathonException {
// 1. check if zk is running, if not start it
Service zkService = Utils.createZookeeperService();
if (!zkService.isRunning()) {
zkService.start(true);
}
List<URI> zkUris = zkService.getServiceDetails();
log.debug("zookeeper service details: {}", zkUris);
// get the zk ip details and pass it to bk, host, controller
URI zkUri = zkUris.get(0);
// 2, check if bk is running, otherwise start, get the zk ip
Service bkService = Utils.createBookkeeperService(zkUri);
if (!bkService.isRunning()) {
bkService.start(true);
}
List<URI> bkUris = bkService.getServiceDetails();
log.debug("bookkeeper service details: {}", bkUris);
// 3. start controller
Service conService = Utils.createPravegaControllerService(zkUri);
if (!conService.isRunning()) {
conService.start(true);
}
List<URI> conUris = conService.getServiceDetails();
log.debug("Pravega Controller service details: {}", conUris);
// 4.start host
Service segService = Utils.createPravegaSegmentStoreService(zkUri, conUris.get(0));
if (!segService.isRunning()) {
segService.start(true);
}
List<URI> segUris = segService.getServiceDetails();
log.debug("pravega host service details: {}", segUris);
}
use of io.pravega.test.system.framework.services.Service in project pravega by pravega.
the class MultiControllerTest method getControllerInfo.
@Before
public void getControllerInfo() {
Service zkService = Utils.createZookeeperService();
Assert.assertTrue(zkService.isRunning());
List<URI> zkUris = zkService.getServiceDetails();
log.info("zookeeper service details: {}", zkUris);
controllerService = Utils.createPravegaControllerService(zkUris.get(0));
List<URI> conUris = controllerService.getServiceDetails();
log.debug("Pravega Controller service details: {}", conUris);
// Fetch all the RPC endpoints and construct the client URIs.
final List<String> uris = conUris.stream().filter(ISGRPC).map(URI::getAuthority).collect(Collectors.toList());
assertEquals("2 controller instances should be running", 2, uris.size());
// use the last two uris
controllerURIDirect.set(URI.create((Utils.TLS_AND_AUTH_ENABLED ? TLS : TCP) + String.join(",", uris)));
log.info("Controller Service direct URI: {}", controllerURIDirect);
controllerURIDiscover.set(URI.create("pravega://" + String.join(",", uris)));
log.info("Controller Service discovery URI: {}", controllerURIDiscover);
segmentStoreService = Utils.createPravegaSegmentStoreService(zkUris.get(0), controllerService.getServiceDetails().get(0));
}
use of io.pravega.test.system.framework.services.Service in project pravega by pravega.
the class MultiSegmentStoreTest method setup.
@Before
public void setup() {
Service zkService = Utils.createZookeeperService();
Assert.assertTrue(zkService.isRunning());
List<URI> zkUris = zkService.getServiceDetails();
log.info("zookeeper service details: {}", zkUris);
// Verify controller is running.
this.controllerInstance = Utils.createPravegaControllerService(zkUris.get(0));
Assert.assertTrue(this.controllerInstance.isRunning());
List<URI> conURIs = this.controllerInstance.getServiceDetails();
log.info("Pravega Controller service instance details: {}", conURIs);
// Verify segment stores is running.
this.segmentServiceInstance = Utils.createPravegaSegmentStoreService(zkUris.get(0), conURIs.get(0));
Assert.assertTrue(this.segmentServiceInstance.isRunning());
Assert.assertEquals(1, this.segmentServiceInstance.getServiceDetails().size());
log.info("Pravega segment store instance details: {}", this.segmentServiceInstance.getServiceDetails());
}
use of io.pravega.test.system.framework.services.Service in project pravega by pravega.
the class PravegaControllerTest method initialize.
/**
* This is used to setup the various services required by the system test framework.
*
* @throws MarathonException if error in setup
*/
@Environment
public static void initialize() throws MarathonException {
Service zk = Utils.createZookeeperService();
if (!zk.isRunning()) {
zk.start(true);
}
Service con = Utils.createPravegaControllerService(zk.getServiceDetails().get(0));
if (!con.isRunning()) {
con.start(true);
}
}
use of io.pravega.test.system.framework.services.Service in project pravega by pravega.
the class PravegaTest method simpleTest.
/**
* Invoke the simpleTest, ensure we are able to produce events.
* The test fails incase of exceptions while writing to the stream.
*/
@Test
public void simpleTest() {
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 SocketConnectionFactoryImpl(Utils.buildClientConfig(controllerUri));
@Cleanup ControllerImpl controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(Utils.buildClientConfig(controllerUri)).build(), connectionFactory.getInternalExecutor());
assertTrue(controller.createScope(STREAM_SCOPE).join());
assertTrue(controller.createStream(STREAM_SCOPE, STREAM_NAME, config).join());
@Cleanup EventStreamClientFactory clientFactory = EventStreamClientFactory.withScope(STREAM_SCOPE, Utils.buildClientConfig(controllerUri));
log.info("Invoking Writer test with Controller URI: {}", controllerUri);
@Cleanup EventStreamWriter<Serializable> writer = clientFactory.createEventWriter(STREAM_NAME, new JavaSerializer<>(), EventWriterConfig.builder().build());
for (int i = 0; i < NUM_EVENTS; i++) {
String event = "Publish " + i + "\n";
log.debug("Producing event: {} ", event);
// any exceptions while writing the event will fail the test.
writer.writeEvent("", event);
writer.flush();
}
log.info("Invoking Reader test.");
ReaderGroupManager groupManager = ReaderGroupManager.withScope(STREAM_SCOPE, Utils.buildClientConfig(controllerUri));
groupManager.createReaderGroup(READER_GROUP, ReaderGroupConfig.builder().stream(Stream.of(STREAM_SCOPE, STREAM_NAME)).build());
@Cleanup EventStreamReader<String> reader = clientFactory.createReader(UUID.randomUUID().toString(), READER_GROUP, new JavaSerializer<>(), ReaderConfig.builder().build());
int readCount = 0;
EventRead<String> event = null;
do {
event = reader.readNextEvent(10_000);
log.debug("Read event: {}.", event.getEvent());
if (event.getEvent() != null) {
readCount++;
}
// try reading until all the written events are read, else the test will timeout.
} while ((event.getEvent() != null || event.isCheckpoint()) && readCount < NUM_EVENTS);
assertEquals("Read count should be equal to write count", NUM_EVENTS, readCount);
}
Aggregations