use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.
the class TestFrameworkTestRun method testAppFromArtifact.
@Test
public void testAppFromArtifact() throws Exception {
ArtifactId artifactId = NamespaceId.DEFAULT.artifact("cfg-app", "1.0.0-SNAPSHOT");
addAppArtifact(artifactId, ConfigTestApp.class);
ApplicationId appId = NamespaceId.DEFAULT.app("AppFromArtifact");
AppRequest<ConfigTestApp.ConfigClass> createRequest = new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), new ConfigTestApp.ConfigClass("testStream", "testDataset"));
ApplicationManager appManager = deployApplication(appId, createRequest);
testAppConfig(appId.getApplication(), appManager, createRequest.getConfig());
}
use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.
the class TestFrameworkTestBase method deployWithArtifact.
/**
* Deploys an {@link Application} using the given artifact jar with an optional config object.
*/
protected static <T> ApplicationManager deployWithArtifact(NamespaceId namespaceId, Class<? extends Application> appClass, File artifactJar, @Nullable T config) throws Exception {
ArtifactId artifactId = new ArtifactId(namespaceId.getNamespace(), appClass.getSimpleName(), "1.0-SNAPSHOT");
addArtifact(artifactId, artifactJar);
AppRequest<T> appRequest = new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), config);
return deployApplication(namespaceId.app(appClass.getSimpleName()), appRequest);
}
use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.
the class LocalArtifactLoaderStage method process.
/**
* Instantiates the Application class and calls configure() on it to generate the {@link ApplicationSpecification}.
*
* @param deploymentInfo information needed to deploy the application, such as the artifact to create it from
* and the application config to use.
*/
@Override
public void process(AppDeploymentInfo deploymentInfo) throws Exception {
ArtifactId artifactId = deploymentInfo.getArtifactId();
Location artifactLocation = deploymentInfo.getArtifactLocation();
String appClassName = deploymentInfo.getAppClassName();
String appVersion = deploymentInfo.getApplicationVersion();
String configString = deploymentInfo.getConfigString();
EntityImpersonator classLoaderImpersonator = new EntityImpersonator(artifactId, impersonator);
ClassLoader artifactClassLoader = artifactRepository.createArtifactClassLoader(artifactLocation, classLoaderImpersonator);
getContext().setProperty(LocalApplicationManager.ARTIFACT_CLASSLOADER_KEY, artifactClassLoader);
InMemoryConfigurator inMemoryConfigurator = new InMemoryConfigurator(cConf, Id.Namespace.fromEntityId(deploymentInfo.getNamespaceId()), Id.Artifact.fromEntityId(artifactId), appClassName, artifactRepository, artifactClassLoader, deploymentInfo.getApplicationName(), deploymentInfo.getApplicationVersion(), configString);
ListenableFuture<ConfigResponse> result = inMemoryConfigurator.config();
ConfigResponse response = result.get(120, TimeUnit.SECONDS);
if (response.getExitCode() != 0) {
throw new IllegalArgumentException("Failed to configure application: " + deploymentInfo);
}
ApplicationSpecification specification = adapter.fromJson(response.get());
ApplicationId applicationId;
if (appVersion == null) {
applicationId = deploymentInfo.getNamespaceId().app(specification.getName());
} else {
applicationId = deploymentInfo.getNamespaceId().app(specification.getName(), appVersion);
}
authorizationEnforcer.enforce(applicationId, authenticationContext.getPrincipal(), Action.ADMIN);
emit(new ApplicationDeployable(deploymentInfo.getArtifactId(), deploymentInfo.getArtifactLocation(), applicationId, specification, store.getApplication(applicationId), ApplicationDeployScope.USER, deploymentInfo.getOwnerPrincipal(), deploymentInfo.canUpdateSchedules()));
}
use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.
the class AuditPublishTest method testPublish.
@Test
public void testPublish() throws Exception {
String defaultNs = NamespaceId.DEFAULT.getNamespace();
String appName = WordCountApp.class.getSimpleName();
// Define expected values
Set<? extends EntityId> expectedMetadataChangeEntities = ImmutableSet.of(Ids.namespace(defaultNs).artifact(WordCountApp.class.getSimpleName(), "1"), Ids.namespace(defaultNs).app(appName), Ids.namespace(defaultNs).app(appName).flow(WordCountApp.WordCountFlow.class.getSimpleName()), Ids.namespace(defaultNs).app(appName).mr(WordCountApp.VoidMapReduceJob.class.getSimpleName()), Ids.namespace(defaultNs).app(appName).service(WordCountApp.WordFrequencyService.class.getSimpleName()), Ids.namespace(defaultNs).dataset("mydataset"), Ids.namespace(defaultNs).stream("text"));
Multimap<AuditType, EntityId> expectedAuditEntities = HashMultimap.create();
expectedAuditEntities.putAll(AuditType.METADATA_CHANGE, expectedMetadataChangeEntities);
expectedAuditEntities.putAll(AuditType.CREATE, ImmutableSet.of(Ids.namespace(defaultNs).dataset("mydataset"), Ids.namespace(defaultNs).stream("text")));
// Deploy application
AppFabricTestHelper.deployApplication(Id.Namespace.DEFAULT, WordCountApp.class, null, cConf);
// Verify audit messages
List<AuditMessage> publishedMessages = fetchAuditMessages();
Multimap<AuditType, EntityId> actualAuditEntities = HashMultimap.create();
for (AuditMessage message : publishedMessages) {
EntityId entityId = message.getEntityId();
if (entityId instanceof NamespacedEntityId) {
if (((NamespacedEntityId) entityId).getNamespace().equals(NamespaceId.SYSTEM.getNamespace())) {
// Ignore system audit messages
continue;
}
}
if (entityId.getEntityType() == EntityType.ARTIFACT && entityId instanceof ArtifactId) {
ArtifactId artifactId = (ArtifactId) entityId;
// Version is dynamic for deploys in test cases
entityId = Ids.namespace(artifactId.getNamespace()).artifact(artifactId.getArtifact(), "1");
}
actualAuditEntities.put(message.getType(), entityId);
}
Assert.assertEquals(expectedAuditEntities, actualAuditEntities);
}
use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.
the class DataQualityAppTest method setup.
@BeforeClass
public static void setup() throws Exception {
appArtifact = NamespaceId.DEFAULT.artifact("dqArtifact", "1.0");
addAppArtifact(appArtifact, DataQualityApp.class, BatchSource.class.getPackage().getName(), PipelineConfigurer.class.getPackage().getName());
ArtifactId pluginArtifactId = NamespaceId.DEFAULT.artifact("source-plugin", "1.0.0-SNAPSHOT");
addPluginArtifact(pluginArtifactId, appArtifact, StreamBatchSource.class, AvroKey.class, GenericRecord.class);
}
Aggregations