public URI createDLMURI(String path) throws Exception { return DLMTestUtil.createDLMURI(zkPort, path); }
@Test(timeout = 60000) public void testCreateLogMetadataOnExistedLog() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; List<String> pathsToDelete = Lists.newArrayList(); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, true); }
@Test(timeout = 60000) public void testCreateLogMetadata() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; List<String> pathsToDelete = Lists.newArrayList(); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, false); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingReadLockPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + READ_LOCK_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingLockPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + LOCK_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingMaxTxIdPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + MAX_TXID_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingVersionPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + VERSION_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingAllocatorPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + ALLOCATION_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingLogSegmentsPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + LOGSEGMENTS_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true); }
@Test(timeout = 60000) public void testCreateLogMetadataMissingAllPath() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; String logRootPath = getLogRootPath(uri, logName, logIdentifier); List<String> pathsToDelete = Lists.newArrayList( logRootPath + LOGSEGMENTS_PATH, logRootPath + MAX_TXID_PATH, logRootPath + LOCK_PATH, logRootPath + READ_LOCK_PATH, logRootPath + VERSION_PATH, logRootPath + ALLOCATION_PATH); testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, true); }
@SuppressWarnings("unchecked") @Test(timeout = 60000, expected = UnexpectedException.class) public void testProcessLogMetadatasMissingMaxTxnId() throws Exception { String rootPath = "/test-missing-max-txn-id"; URI uri = DLMTestUtil.createDLMURI(2181, rootPath); String logName = "test-log"; String logIdentifier = "<default>"; List<Versioned<byte[]>> metadatas = Lists.newArrayList( new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null)); ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false); }
@BeforeClass public static void setupDefaults() throws Exception { defaultUri = DLMTestUtil.createDLMURI(zkPort, defaultPath); DistributedLogManager dlm = DLMTestUtil.createNewDLM("DefaultStream", conf, defaultUri); bindStream(defaultUri, defaultLedgerPath, defaultHost); DLMTestUtil.generateCompletedLogSegments(dlm, conf, 3, 8192); dlm.close(); }
@Test(timeout = 60000, expected = LogNotFoundException.class) public void testCreateLogMetadataWithCreateIfNotExistsSetToFalse() throws Exception { URI uri = DLMTestUtil.createDLMURI(zkPort, ""); String logName = testName.getMethodName(); String logIdentifier = "<default>"; FutureUtils.result(ZKLogMetadataForWriter.of(uri, logName, logIdentifier, zkc.get(), zkc.getDefaultACL(), true, false)); }
@Before public void setup() throws Exception { zkc = TestZooKeeperClientBuilder.newBuilder() .name("zkc") .uri(DLMTestUtil.createDLMURI(zkPort, "/")) .sessionTimeoutMs(sessionTimeoutMs) .build(); }
@Before public void setup() throws Exception { zkc = TestZooKeeperClientBuilder.newBuilder() .name("zkc") .uri(DLMTestUtil.createDLMURI(zkPort, "/")) .sessionTimeoutMs(sessionTimeoutMs) .build(); }
@SuppressWarnings("unchecked") @Test(timeout = 60000, expected = UnexpectedException.class) public void testProcessLogMetadatasMissingVersion() throws Exception { String rootPath = "/test-missing-version"; URI uri = DLMTestUtil.createDLMURI(2181, rootPath); String logName = "test-log"; String logIdentifier = "<default>"; List<Versioned<byte[]>> metadatas = Lists.newArrayList( new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(null, null)); ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false); }
private ZooKeeperClientBuilder clientBuilder(int sessionTimeoutMs) throws Exception { return ZooKeeperClientBuilder.newBuilder() .name("zkc") .uri(DLMTestUtil.createDLMURI(zkPort, "/")) .sessionTimeoutMs(sessionTimeoutMs) .zkServers(zkServers) .retryPolicy(new BoundExponentialBackoffRetryPolicy(100, 200, 2)); }
@SuppressWarnings("unchecked") @Test(timeout = 60000, expected = UnexpectedException.class) public void testProcessLogMetadatasWrongVersion() throws Exception { String rootPath = "/test-missing-version"; URI uri = DLMTestUtil.createDLMURI(2181, rootPath); String logName = "test-log"; String logIdentifier = "<default>"; List<Versioned<byte[]>> metadatas = Lists.newArrayList( new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(9999), null)); ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false); }
@SuppressWarnings("unchecked") @Test(timeout = 60000, expected = UnexpectedException.class) public void testProcessLogMetadatasMissingLockPath() throws Exception { String rootPath = "/test-missing-version"; URI uri = DLMTestUtil.createDLMURI(2181, rootPath); String logName = "test-log"; String logIdentifier = "<default>"; List<Versioned<byte[]>> metadatas = Lists.newArrayList( new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(null, null)); ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false); }
@SuppressWarnings("unchecked") @Test(timeout = 60000, expected = UnexpectedException.class) public void testProcessLogMetadatasMissingReadLockPath() throws Exception { String rootPath = "/test-missing-version"; URI uri = DLMTestUtil.createDLMURI(2181, rootPath); String logName = "test-log"; String logIdentifier = "<default>"; List<Versioned<byte[]>> metadatas = Lists.newArrayList( new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(null, null)); ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false); }