use of io.cdap.cdap.StandaloneTester in project cdap by caskdata.
the class MetadataHttpHandlerTestRun method testSystemScopeArtifacts.
@Test
public void testSystemScopeArtifacts() throws Exception {
// add a system artifact. currently can't do this through the rest api (by design)
// so bypass it and use the repository directly
ArtifactId systemId = NamespaceId.SYSTEM.artifact("app", "1.0.0");
File systemArtifact = createArtifactJarFile(AllProgramsApp.class, "app", "1.0.0", new Manifest());
StandaloneTester tester = STANDALONE.get();
tester.addSystemArtifact(systemId.getArtifact(), Id.Artifact.fromEntityId(systemId).getVersion(), systemArtifact, null);
// wait until the system metadata has been processed
Tasks.waitFor(false, () -> getProperties(systemId, MetadataScope.SYSTEM).isEmpty(), 10, TimeUnit.SECONDS);
// verify that user metadata can be added for system-scope artifacts
Map<String, String> userProperties = ImmutableMap.of("systemArtifactKey", "systemArtifactValue");
Set<String> userTags = ImmutableSet.of();
addProperties(systemId, userProperties);
addTags(systemId, userTags);
// verify that user and system metadata can be retrieved for system-scope artifacts
Assert.assertEquals(ImmutableSet.of(new MetadataRecord(systemId, MetadataScope.USER, userProperties, userTags), new MetadataRecord(systemId, MetadataScope.SYSTEM, ImmutableMap.of(MetadataConstants.ENTITY_NAME_KEY, systemId.getEntityName()), ImmutableSet.of())), removeCreationTime(getMetadata(systemId.toMetadataEntity())));
// verify that system scope artifacts can be returned by a search in the default namespace
// with no target type
MetadataSearchResponse response = searchMetadata(ImmutableList.of(NamespaceId.DEFAULT, NamespaceId.SYSTEM), "system*");
MetadataEntity expectedEntity = systemId.toMetadataEntity();
Set<MetadataEntity> actualEntities = new HashSet<>(extractMetadataEntities(response.getResults()));
Assert.assertTrue(actualEntities.contains(expectedEntity));
// with target type as artifact
assertSearch(searchMetadata(ImmutableList.of(NamespaceId.DEFAULT, NamespaceId.SYSTEM), "system*", MetadataEntity.ARTIFACT), systemId);
// verify that user metadata can be deleted for system-scope artifacts
removeMetadata(systemId);
Assert.assertEquals(ImmutableSet.of(new MetadataRecord(systemId, MetadataScope.USER, ImmutableMap.of(), ImmutableSet.of()), new MetadataRecord(systemId, MetadataScope.SYSTEM, ImmutableMap.of(MetadataConstants.ENTITY_NAME_KEY, systemId.getEntityName()), ImmutableSet.of())), removeCreationTime(getMetadata(systemId.toMetadataEntity())));
artifactClient.delete(systemId);
}
use of io.cdap.cdap.StandaloneTester in project cdap by caskdata.
the class AbstractClientTest method setUp.
@Before
public void setUp() throws Throwable {
StandaloneTester standalone = getStandaloneTester();
ConnectionConfig connectionConfig = InstanceURIParser.DEFAULT.parse(standalone.getBaseURI().toString());
clientConfig = new ClientConfig.Builder().setVerifySSLCert(false).setDefaultReadTimeout(60 * 1000).setUploadReadTimeout(120 * 1000).setConnectionConfig(connectionConfig).build();
}
Aggregations