use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayTestDriver method setupGateway.
/**
* Creates a GATEWAY_HOME, starts a gateway instance and deploys a test topology.
*/
public void setupGateway(GatewayTestConfig config, String cluster, XMLTag topology, boolean use) throws Exception {
this.useGateway = use;
this.config = config;
this.clusterName = cluster;
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
config.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(config.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(config.getGatewayDeploymentDir());
deployDir.mkdirs();
File descriptor = new File(topoDir, cluster + ".xml");
FileOutputStream stream = new FileOutputStream(descriptor);
topology.toStream(stream);
stream.close();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
srvcs.init(config, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(config, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, CoreMatchers.notNullValue());
log.info("Gateway port = " + gateway.getAddresses()[0].getPort());
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class AmbariServiceDefinitionTest method startGatewayServer.
public static void startGatewayServer() throws Exception {
services = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
services.init(config, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
topos = services.getService(GatewayServices.TOPOLOGY_SERVICE);
gateway = GatewayServer.startGateway(config, services);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
gatewayPort = gateway.getAddresses()[0].getPort();
gatewayUrl = "http://localhost:" + gatewayPort + "/" + config.getGatewayPath();
String topologyPath = "/test-topology";
clusterPath = "/" + config.getGatewayPath() + topologyPath;
clusterUrl = gatewayUrl + topologyPath;
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
params = new Properties();
params.put("AMBARI_URL", "http://localhost:" + mockAmbari.getPort());
velocity = new VelocityEngine();
velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem");
velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
velocity.init();
context = new VelocityContext();
context.put("cluster_url", clusterUrl);
context.put("cluster_path", clusterPath);
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayAdminTopologyFuncTest method setupGateway.
public static void setupGateway(GatewayTestConfig testConfig) throws Exception {
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
config = testConfig;
testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(testConfig.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(testConfig.getGatewayDeploymentDir());
deployDir.mkdirs();
File providerConfigDir = new File(testConfig.getGatewayConfDir(), "shared-providers");
providerConfigDir.mkdirs();
File descriptorsDir = new File(testConfig.getGatewayConfDir(), "descriptors");
descriptorsDir.mkdirs();
File descriptor = new File(topoDir, "admin.xml");
FileOutputStream stream = new FileOutputStream(descriptor);
createKnoxTopology().toStream(stream);
stream.close();
File descriptor2 = new File(topoDir, "test-cluster.xml");
FileOutputStream stream2 = new FileOutputStream(descriptor2);
createNormalTopology().toStream(stream2);
stream.close();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
srvcs.init(testConfig, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(testConfig, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/admin";
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayAppFuncTest method startGatewayServer.
public static void startGatewayServer() throws Exception {
services = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
services.init(config, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
topos = services.getService(GatewayServices.TOPOLOGY_SERVICE);
gateway = GatewayServer.startGateway(config, services);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
gatewayPort = gateway.getAddresses()[0].getPort();
gatewayUrl = "http://localhost:" + gatewayPort + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-topology";
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
params = new Properties();
params.put("LDAP_URL", driver.getLdapUrl());
params.put("WEBHDFS_URL", "http://localhost:" + mockWebHdfs.getPort());
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayCorrelationIdTest method setupGateway.
public static void setupGateway() throws Exception {
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
GatewayTestConfig testConfig = new GatewayTestConfig();
config = testConfig;
testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(testConfig.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(testConfig.getGatewayDeploymentDir());
deployDir.mkdirs();
File descriptor = new File(topoDir, "test-cluster.xml");
FileOutputStream stream = new FileOutputStream(descriptor);
createTopology().toStream(stream);
stream.close();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
srvcs.init(testConfig, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(testConfig, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
}
Aggregations