protected void deleteSpace(SpaceConfig spaceConfig, String version) throws NamespaceException { namespaceService.deleteSpace(new NamespaceKey(spaceConfig.getName()), version); }
@DELETE @Produces(MediaType.APPLICATION_JSON) public void deleteSpace(@QueryParam("version") String version) throws NamespaceException, SpaceNotFoundException, UserException { if (version == null) { throw new ClientErrorException("missing version parameter"); } try { namespaceService.deleteSpace(spacePath.toNamespaceKey(), version); } catch (NamespaceNotFoundException nfe) { throw new SpaceNotFoundException(spacePath.getSpaceName().getName(), nfe); } }
namespace.deleteSpace(new NamespaceKey(space.getName()), space.getTag());
@AfterClass public static void after() throws Exception { NamespaceService namespaceService = newNamespaceService(); NamespaceKey namespaceKey = new NamespaceKey("searchSpace"); namespaceService.deleteSpace(namespaceKey, namespaceService.getSpace(namespaceKey).getTag()); }
@Test public void testDeleteSpace() throws Exception { Space space = new Space("space-id", "mySpace", "1", 0L, null); NameSpaceContainer namespaceContainer = new NameSpaceContainer(); namespaceContainer.setSpace(catalogServiceHelper.getSpaceConfig(space)); namespaceContainer.setType(NameSpaceContainer.Type.SPACE); when(namespaceService.getEntityById(space.getId())).thenReturn(namespaceContainer); catalogServiceHelper.deleteCatalogItem(space.getId(), space.getTag()); verify(namespaceService, times(1)).deleteSpace(new NamespaceKey(space.getName()), space.getTag()); }
public void deleteSpace() { NamespaceKey key = new SpacePath(TEST_SPACE).toNamespaceKey(); SpaceConfig config; try { config = getNamespaceService().getSpace(key); if (config != null) { getNamespaceService().deleteSpace(key, config.getTag()); } }catch (NamespaceException e) { } }
@AfterClass public static void shutdown() throws Exception { // setup space NamespaceKey key = new NamespaceKey("mySpace"); SpaceConfig space = newNamespaceService().getSpace(key); newNamespaceService().deleteSpace(key, space.getTag()); }
@AfterClass public static void shutdown() throws Exception { // setup space NamespaceKey key = new NamespaceKey("dsvTest"); SpaceConfig space = newNamespaceService().getSpace(key); newNamespaceService().deleteSpace(key, space.getTag()); }
public static void cleanup(DACDaemon dremioDaemon) throws Exception { final NamespaceService namespaceService = newNamespaceService(); namespaceService.deleteSpace(new SpacePath("testA").toNamespaceKey(), namespaceService.getSpace(new SpacePath("testA").toNamespaceKey()).getTag()); namespaceService.deleteSpace(new SpacePath("testB").toNamespaceKey(), namespaceService.getSpace(new SpacePath("testB").toNamespaceKey()).getTag()); }
@Test public void testSetTagsErrors() throws Exception { List<String> tagList = Arrays.asList("tag1", "tag2"); Tags newTags = new Tags(tagList, null); // set tags for an invalid id expectStatus(BAD_REQUEST, getBuilder(getPublicAPI(3).path("catalog").path("bad-id").path("collaboration").path("tag")).buildPost(Entity.json(newTags))); // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); // set invalid tags (duplicate) tagList = Arrays.asList("tag1", "tag2", "tag1"); newTags = new Tags(tagList, null); expectStatus(BAD_REQUEST, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags))); // update tags with invalid version tagList = Arrays.asList("tag1", "tag2"); newTags = new Tags(tagList, null); expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags))); newTags = new Tags(tagList, "5"); expectStatus(CONFLICT, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags))); // test tag size limit - 128 max tagList = Arrays.asList("tag1", Strings.repeat("tag", 43)); newTags = new Tags(tagList, null); expectStatus(BAD_REQUEST, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags))); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testGetTags() throws Exception { // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); // no tags initially, so expect a 404 expectStatus(NOT_FOUND, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildGet()); CollaborationHelper collaborationHelper = l(CollaborationHelper.class); List<String> tagList = Arrays.asList("tag1", "tag2"); Tags newTags = new Tags(tagList, null); collaborationHelper.setTags(dataset.getId().getId(), newTags); // tags exist now Tags tags = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildGet(), Tags.class); assertEquals(tags.getTags().size(), 2); assertTrue(tags.getTags().containsAll(tagList)); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testSetWikiErrors() throws Exception { Wiki newWiki = new Wiki("sample wiki text", null); // set tags for an invalid id expectStatus(BAD_REQUEST, getBuilder(getPublicAPI(3).path("catalog").path("bad-id").path("collaboration").path("wiki")).buildPost(Entity.json(newWiki))); // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); // update tags with invalid version newWiki = new Wiki("sample wiki text", null); expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildPost(Entity.json(newWiki))); newWiki = new Wiki("sample wiki text", 5L); expectStatus(CONFLICT, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildPost(Entity.json(newWiki))); // test wiki test size limit - 100k max //newWiki = new Wiki(Strings.repeat("f", 100_001), "0"); //expectStatus(BAD_REQUEST, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildPost(Entity.json(newWiki))); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testVDSConcurrency() throws Exception { Space newSpace = new Space(null, "concurrency", null, null, null); Space space = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newSpace)), new GenericType<Space>() {}); int max = 5; List<Thread> threads = new ArrayList<>(); for (int i = 1; i <= max; i++) { threads.add(createVDSInSpace("vds" + i, space.getName(), "select " + i)); } threads.forEach(Thread::start); for (Thread thread : threads) { thread.join(); } // verify that the VDS were created with the correct SQL for (int i = 1; i <= max; i++) { DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(Arrays.asList(space.getName(), "vds" + i))); assertEquals(dataset.getVirtualDataset().getSql(), "select " + i); } newNamespaceService().deleteSpace(new NamespaceKey(space.getName()), space.getTag()); }
@Test public void testGetWiki() throws Exception { // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); // no tags initially, so expect a 404 expectStatus(NOT_FOUND, getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildGet()); CollaborationHelper collaborationHelper = l(CollaborationHelper.class); Wiki newWiki = new Wiki("sample wiki text", null); collaborationHelper.setWiki(dataset.getId().getId(), newWiki); // tags exist now Wiki wiki = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildGet(), Wiki.class); assertEquals(wiki.getText(), newWiki.getText()); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testSetWiki() throws Exception { // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); // create wiki Wiki newWiki = new Wiki("sample wiki text", null); Wiki wiki = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildPost(Entity.json(newWiki)), Wiki.class); assertEquals(wiki.getText(), newWiki.getText()); assertEquals(wiki.getVersion().longValue(), 0L); // update wiki newWiki = new Wiki("some text", wiki.getVersion()); expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildPost(Entity.json(newWiki))); wiki = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("wiki")).buildGet(), Wiki.class); assertEquals(wiki.getText(), newWiki.getText()); assertEquals(wiki.getVersion().longValue(), 1L); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testSetTags() throws Exception { // create space NamespaceKey spacePath = new NamespaceKey("testspace"); List<String> vdsPath = Arrays.asList(spacePath.getRoot(), "testVDS"); createSpaceAndVDS(spacePath, vdsPath); DatasetConfig dataset = newNamespaceService().getDataset(new NamespaceKey(vdsPath)); List<String> tagList = Arrays.asList("tag1", "tag2"); Tags newTags = new Tags(tagList, null); Tags tags = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags)), Tags.class); assertEquals(tags.getTags().size(), 2); assertTrue(tags.getTags().containsAll(tagList)); assertEquals(tags.getVersion(), "0"); // test update of existing tags tagList = Arrays.asList("tag1", "tag3"); newTags = new Tags(tagList, tags.getVersion()); tags = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags)), Tags.class); // verify the new tags assertEquals(tags.getTags().size(), 2); assertTrue(tags.getTags().containsAll(tagList)); assertEquals(tags.getVersion(), "1"); // clear out tags tagList = Arrays.asList(); newTags = new Tags(tagList, tags.getVersion()); tags = expectSuccess(getBuilder(getPublicAPI(3).path("catalog").path(dataset.getId().getId()).path("collaboration").path("tag")).buildPost(Entity.json(newTags)), Tags.class); // verify the new tags are empty assertEquals(tags.getTags().size(), 0); // cleanup space newNamespaceService().deleteSpace(spacePath, NamespaceUtils.getVersion(spacePath, newNamespaceService())); }
@Test public void testFoldersInSpace() throws Exception { // create a new space Space newSpace = new Space(null, "final frontier", null, null, null); Space space = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newSpace)), new GenericType<Space>() {}); // no children at this point assertNull(space.getChildren()); // add a folder Folder newFolder = new Folder(null, Arrays.asList(space.getName(), "myFolder"), null, null); Folder folder = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newFolder)), new GenericType<Folder>() {}); assertEquals(newFolder.getPath(), folder.getPath()); // make sure folder shows up under space space = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(space.getId())).buildGet(), new GenericType<Space>() {}); // make sure that trying to create the folder again fails expectStatus(Response.Status.CONFLICT, getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newFolder))); // one child at this point assertEquals(space.getChildren().size(), 1); assertEquals(space.getChildren().get(0).getId(), folder.getId()); // delete the folder expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(folder.getId())).buildDelete()); space = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(space.getId())).buildGet(), new GenericType<Space>() {}); assertEquals(space.getChildren().size(), 0); newNamespaceService().deleteSpace(new NamespaceKey(space.getName()), space.getTag()); }
assertEquals(0, folder.getChildren().size()); newNamespaceService().deleteSpace(new NamespaceKey(space.getName()), space.getTag());
@Test public void testCTASReplace() throws Exception { NamespaceKey namespaceKey = new NamespaceKey("ctasSpace"); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("ctasSpace"); newNamespaceService().addOrUpdateSpace(namespaceKey, spaceConfig); SqlQuery ctas = getQueryFromSQL("CREATE OR REPLACE VIEW ctasSpace.ctastest AS select * from (VALUES (1))"); Job ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .setQueryType(QueryType.UI_RUN) .build(), NoOpJobStatusListener.INSTANCE); waitForCompletion(ctasJob); ctas = getQueryFromSQL("CREATE OR REPLACE VIEW ctasSpace.ctastest AS select * from (VALUES (2))"); ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .setQueryType(QueryType.UI_RUN) .build(), NoOpJobStatusListener.INSTANCE); waitForCompletion(ctasJob); newNamespaceService().deleteSpace(namespaceKey, newNamespaceService().getSpace(namespaceKey).getTag()); }
namespaceService.deleteSpace(new NamespaceKey("space1"), "1234"); fail("deleteSpace didn't throw exception"); } catch (ConcurrentModificationException nfe) { namespaceService.deleteSpace(new NamespaceKey("space1"), space1.getTag()); try { namespaceService.getSpace(new NamespaceKey("space1")); } catch (NamespaceNotFoundException nfe) { namespaceService.deleteSpace(new NamespaceKey("space2"), space2.getTag()); try { namespaceService.getSpace(new NamespaceKey("space2"));