@Override void perform() throws IOException { NamespaceDescriptor selected = selectNamespace(namespaceMap); if (selected == null) { return; } Admin admin = connection.getAdmin(); try { String namespaceName = selected.getName(); LOG.info("Deleting namespace :" + selected); admin.deleteNamespace(namespaceName); try { if (admin.getNamespaceDescriptor(namespaceName) != null) { // the namespace still exists. Assert.assertTrue("Namespace: " + selected + " was not deleted", false); } else { LOG.info("Deleted namespace :" + selected); } } catch (NamespaceNotFoundException nsnfe) { // This is expected result LOG.info("Deleted namespace :" + selected); } } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
private NamespaceDescriptor createNamespaceDesc() { String namespaceName = "itnamespace" + String.format("%010d", RandomUtils.nextInt(Integer.MAX_VALUE)); NamespaceDescriptor nsd = NamespaceDescriptor.create(namespaceName).build(); nsd.setConfiguration( nsTestConfigKey, String.format("%010d", RandomUtils.nextInt(Integer.MAX_VALUE))); return nsd; }
@Override void perform() throws IOException { NamespaceDescriptor selected = selectNamespace(namespaceMap); if (selected == null) { return; } Admin admin = connection.getAdmin(); try { String namespaceName = selected.getName(); LOG.info("Modifying namespace :" + selected); NamespaceDescriptor modifiedNsd = NamespaceDescriptor.create(namespaceName).build(); String nsValueNew; do { nsValueNew = String.format("%010d", RandomUtils.nextInt(Integer.MAX_VALUE)); } while (selected.getConfigurationValue(nsTestConfigKey).equals(nsValueNew)); modifiedNsd.setConfiguration(nsTestConfigKey, nsValueNew); admin.modifyNamespace(modifiedNsd); NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(namespaceName); Assert.assertTrue( "Namespace: " + selected + " was not modified", freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew)); LOG.info("Modified namespace :" + freshNamespaceDesc); namespaceMap.put(namespaceName, freshNamespaceDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
@Override void perform() throws IOException { Admin admin = connection.getAdmin(); try { NamespaceDescriptor nsd; while (true) { nsd = createNamespaceDesc(); try { if (admin.getNamespaceDescriptor(nsd.getName()) != null) { // the namespace has already existed. continue; } else { // currently, the code never return null - always throws exception if // namespace is not found - this just a defensive programming to make // sure null situation is handled in case the method changes in the // future. break; } } catch (NamespaceNotFoundException nsnfe) { // This is expected for a random generated NamespaceDescriptor break; } } LOG.info("Creating namespace:" + nsd); admin.createNamespace(nsd); NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(nsd.getName()); Assert.assertTrue("Namespace: " + nsd + " was not created", freshNamespaceDesc != null); LOG.info("Created namespace:" + freshNamespaceDesc); namespaceMap.put(nsd.getName(), freshNamespaceDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
@Override public void cleanUpCluster() throws Exception { if (!keepObjectsAtTheEnd) { Admin admin = util.getAdmin(); admin.disableTables("ittable-\\d+"); admin.deleteTables("ittable-\\d+"); NamespaceDescriptor[] nsds = admin.listNamespaceDescriptors(); for (NamespaceDescriptor nsd : nsds) { if (nsd.getName().matches("itnamespace\\d+")) { LOG.info("Removing namespace=" + nsd.getName()); admin.deleteNamespace(nsd.getName()); } } } enabledTables.clear(); disabledTables.clear(); deletedTables.clear(); namespaceMap.clear(); Connection connection = getConnection(); connection.close(); super.cleanUpCluster(); }