Search in sources :

Example 6 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class LocalFileSystemUploaderTest method testUploadPackageWhenFileSystemDirectoryIsInvalid.

@Test(expected = IllegalArgumentException.class)
public void testUploadPackageWhenFileSystemDirectoryIsInvalid() {
    // identify the location of the test topology tar file
    String topologyPackage = Paths.get(testTopologyDirectory, TOPOLOGY_PACKAGE_FILE_NAME).toString();
    String invalidFileSystemDirectory = "invalid%path";
    // set invalid file system directory
    Config newConfig = Config.newBuilder().putAll(config).put(Key.TOPOLOGY_PACKAGE_FILE, topologyPackage).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), invalidFileSystemDirectory).build();
    // create the uploader and load the package
    LocalFileSystemUploader uploader = new LocalFileSystemUploader();
    uploader.initialize(newConfig);
    uploader.uploadPackage();
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 7 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class LocalFileSystemConfigTest method testOverrideConfig.

@Test
public void testOverrideConfig() throws Exception {
    String overrideDirectory = "/users/twitter";
    Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
    Assert.assertEquals(LocalFileSystemContext.getFileSystemDirectory(config), overrideDirectory);
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 8 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class LocalFileSystemConfigTest method testTopologyFile.

@Test
public void testTopologyFile() throws Exception {
    Config config = Config.toLocalMode(getDefaultConfig());
    LocalFileSystemUploader uploader = new LocalFileSystemUploader();
    uploader.initialize(config);
    Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), LocalFileSystemContext.getFileSystemDirectory(config));
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 9 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class LocalFileSystemContextTest method testGetFileSystemDirectory.

@Test
public void testGetFileSystemDirectory() {
    String fileSystemDirectory = "${HOME}/.herondata/topologies/${CLUSTER}";
    Config config = Config.newBuilder().put(Key.CLUSTER, "cluster").put(Key.ROLE, "role").put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), fileSystemDirectory).build();
    // get actual file system directory set by the user
    String actualFileSystemDirectory = LocalFileSystemContext.getFileSystemDirectory(config);
    String expectedFileSystemDirectory = Paths.get("${HOME}", ".herondata", "topologies", "${CLUSTER}").toString();
    Assert.assertEquals(expectedFileSystemDirectory, actualFileSystemDirectory);
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 10 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class RegistryTest method testGetDownloader.

@Test
public void testGetDownloader() throws Exception {
    Map<String, String> protocols = new HashMap<>();
    protocols.put("http", "org.apache.heron.downloader.HttpDownloader");
    protocols.put("https", "org.apache.heron.downloader.HttpDownloader");
    protocols.put("distributedlog", "org.apache.heron.downloader.DLDownloader");
    protocols.put("file", "org.apache.heron.downloader.FileDownloader");
    Config config = Config.newBuilder().put("heron.downloader.registry", protocols).build();
    Map<String, Class<? extends Downloader>> downloaders = new HashMap<>();
    downloaders.put("http", HttpDownloader.class);
    downloaders.put("https", HttpDownloader.class);
    downloaders.put("distributedlog", DLDownloader.class);
    downloaders.put("file", FileDownloader.class);
    URI httpUri = URI.create("http://127.0.0.1/test/http");
    Class<? extends Downloader> clazz = Registry.UriToClass(config, httpUri);
    Downloader downloader = Registry.getDownloader(clazz, httpUri);
    assertTrue(downloader instanceof HttpDownloader);
    URI httpsUri = URI.create("https://127.0.0.1/test/http");
    clazz = Registry.UriToClass(config, httpsUri);
    downloader = Registry.getDownloader(clazz, httpsUri);
    assertTrue(downloader instanceof HttpDownloader);
    URI dlUri = URI.create("distributedlog://127.0.0.1/test/distributedlog");
    clazz = Registry.UriToClass(config, dlUri);
    downloader = Registry.getDownloader(clazz, dlUri);
    assertTrue(downloader instanceof DLDownloader);
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.spi.common.Config) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Config (org.apache.heron.spi.common.Config)140 Test (org.junit.Test)75 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 PackingPlan (org.apache.heron.spi.packing.PackingPlan)22 HashMap (java.util.HashMap)18 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)18 Pair (org.apache.heron.common.basics.Pair)16 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)15 IOException (java.io.IOException)11 LauncherUtils (org.apache.heron.scheduler.utils.LauncherUtils)11 Map (java.util.Map)10 V1Volume (io.kubernetes.client.openapi.models.V1Volume)9 URI (java.net.URI)9 IScheduler (org.apache.heron.spi.scheduler.IScheduler)9 IStateManager (org.apache.heron.spi.statemgr.IStateManager)9 Before (org.junit.Before)9 File (java.io.File)7 LinkedList (java.util.LinkedList)7 Resource (org.apache.heron.spi.packing.Resource)7 CommandLine (org.apache.commons.cli.CommandLine)6