use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class BasicbookstoreDnsPaasTest method CreateLbSharedService.
/* Creates LB as a shared service */
public void CreateLbSharedService(GlassFish glassfish) throws Exception {
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
String template = checkMode(glassfish);
if (template.equalsIgnoreCase("Native")) {
template = "LBNative";
} else if (template.equalsIgnoreCase("kvm")) {
template = "apachemodjk";
} else {
template = "otd-new";
}
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("create-shared-service", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("template", template);
parameterMap.add("configuration", "http-port=50080:https-port=50081:ssl-enabled=true:health-check-interval=60:health-check-timeout=10");
parameterMap.add("servicetype", "LB");
parameterMap.add("DEFAULT", "hudson-shared-lb-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'hudson-shared-lb-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class BasicbookstoreDnsPaasTest method CreateDNSExternalService.
/*Create DNS external shared service*/
public void CreateDNSExternalService() {
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("create-external-service", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("servicetype", "DNS");
parameterMap.add("configuration", "domain-name=hudson.com:dns-ip=10.178.214.173:dns-private-key-file-loc=" + System.getenv("PAAS_TESTS_HOME") + "/basic-bookstore-dns/Kkey-glassfish.+157+05094.private");
parameterMap.add("DEFAULT", "hudson-dns-external-services");
invocation.parameters(parameterMap).execute();
System.out.println("Created external service 'hudson-dns-external-services' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class BasicDBInitSqlTest method testListServices.
private void testListServices() {
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
// Testing for the '--output' option of lst-services sub-commands
{
List<String> outputOptions = new ArrayList<String>();
outputOptions.add("SERVICE-NAME");
outputOptions.add("VM-ID");
outputOptions.add("SERVER-TYPE");
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("output", "service-name,vm-id,server-type");
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
Map<String, String> map = list.get(0);
Set set = map.keySet();
outputOptions.removeAll(set);
boolean isEmpty = outputOptions.isEmpty();
System.out.println("list-services --output option test passed:: " + isEmpty);
Assert.assertTrue(isEmpty);
}
// Testing for the '--key' option of lst-services sub-commands
{
String key = "VM-ID";
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("key", key);
parameterMap.add("output", key);
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
ListIterator listIterator = list.listIterator();
List<String> valueList = new ArrayList<String>();
Map<String, String> map;
while (listIterator.hasNext()) {
map = (Map<String, String>) listIterator.next();
valueList.add(map.get(key));
}
boolean isSorted = isSortedList(valueList);
System.out.println("list-services --key option test passed:: " + isSorted);
Assert.assertTrue(isSorted);
}
// Testing for the '--type' option of lst-services sub-commands
{
String type = "DATABASE";
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("type", type);
parameterMap.add("output", "SERVER-TYPE");
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
ListIterator listIterator = list.listIterator();
List<String> valueList = new ArrayList<String>();
Map<String, String> map;
String typeFound = null;
boolean onlyTypeFound = false;
while (listIterator.hasNext()) {
map = (Map<String, String>) listIterator.next();
typeFound = (String) map.get("SERVER-TYPE");
if (type.equals(typeFound)) {
onlyTypeFound = true;
} else {
onlyTypeFound = false;
break;
}
}
if (valueList.isEmpty()) {
onlyTypeFound = true;
}
System.out.println("list-services --type option test passed:: " + onlyTypeFound);
Assert.assertTrue(onlyTypeFound);
}
// Testing for the '--scope' option of lst-services sub-commands
// Here, the war deployed is 'basic_db_initsql_paas_sample.war', hence using it as the appname.
{
String scope = "application";
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("scope", scope);
parameterMap.add("output", "SCOPE");
parameterMap.add("appname", "basic_db_initsql_paas_sample");
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
ListIterator listIterator = list.listIterator();
List<String> valueList = new ArrayList<String>();
Map<String, String> map;
String scopeFound = null;
boolean onlyScopeFound = false;
while (listIterator.hasNext()) {
map = (Map<String, String>) listIterator.next();
scopeFound = (String) map.get("SCOPE");
if (scope.equals(scopeFound)) {
onlyScopeFound = true;
} else {
onlyScopeFound = false;
break;
}
}
if (valueList.isEmpty()) {
onlyScopeFound = true;
}
System.out.println("list-services --scope option test passed:: " + onlyScopeFound);
Assert.assertTrue(onlyScopeFound);
}
// test the option --terse=false.
{
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("output", "service-name,vm-id,server-type");
parameterMap.add("terse", "true");
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
boolean headersNotFound = false;
for (Map<String, String> map : list) {
headersNotFound = false;
Set<String> headers = map.keySet();
for (String header : headers) {
if ("".equals(header)) {
headersNotFound = true;
} else {
headersNotFound = false;
break;
}
}
if (!headersNotFound) {
break;
}
}
System.out.println("list-services --terse=true option test passed:: " + headersNotFound);
Assert.assertTrue(headersNotFound);
}
// test --type option
{
String typeValue = "Javaee";
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("list-services", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("output", "server-type");
parameterMap.add("type", typeValue);
invocation.parameters(parameterMap).execute();
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
boolean otherTypeFound = false;
for (Map<String, String> map : list) {
String value = map.get("SERVER-TYPE");
if (!value.equalsIgnoreCase(typeValue)) {
otherTypeFound = true;
break;
}
}
System.out.println("list-services --type option test passed:: " + !otherTypeFound);
Assert.assertFalse(otherTypeFound);
}
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ExtSharedServiceEnableDisableTest method createSharedAndExternalServices.
private void createSharedAndExternalServices(String ipAddress_DAS) {
System.out.println("################### Trying to Create External and Shared Service #######################");
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
// Created external service of type JavaEE
// asadmin create-shared-service --servicetype=JavaEE --configuration min.clustersize=2:max.clustersize=4 --characteristics service-type=JavaEE my-shared-gf-service.
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("create-shared-service", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("servicetype", "JavaEE");
parameterMap.add("characteristics", "service-type=JavaEE");
parameterMap.add("configuration", "min.clustersize=2:max.clustersize=4");
parameterMap.add("DEFAULT", "my-shared-gf-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-gf-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// Create external service of type Database
// asadmin create-external-service --servicetype=Database --configuration ip-address=127.0.0.1:databasename=sun-appserv-samples:port=1527:user=APP:password=APP:host=127.0.0.1:classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource my-external-db-service
invocation = commandRunner.getCommandInvocation("create-external-service", report);
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "Database");
parameterMap.add("configuration", "ip-address=" + ipAddress_DAS + ":databasename=sun-appserv-samples:connectionAttributes=;'create=true':port=1527:user=APP:password=APP:host=" + ipAddress_DAS + ":classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource");
// parameterMap.add("configuration", "ip-address=127.0.0.1:databasename=${com.sun.aas.installRoot}/databases/sun-appserv-samples:port=1527:user=APP:password=APP:connectionAttributes=;'create\\=true':host=127.0.0.1:classname=org.apache.derby.jdbc.EmbeddedXADataSource:resourcetype=javax.sql.XADataSource");
parameterMap.add("DEFAULT", "my-external-db-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created external service 'my-external-db-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// Create shared service of type LB
// asadmin create-shared-service --characteristics service-type=LB --configuration http-port=50080:https-port=50081:ssl-enabled=true --servicetype LB my-shared-lb-service
invocation = commandRunner.getCommandInvocation("create-shared-service", report);
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "LB");
parameterMap.add("characteristics", "service-type=LB");
parameterMap.add("configuration", "http-port=50080:https-port=50081:ssl-enabled=true");
parameterMap.add("DEFAULT", "my-shared-lb-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-lb-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// List the services and check the status of both the services - it should be 'RUNNING'
invocation = commandRunner.getCommandInvocation("list-services", report);
parameterMap = new ParameterMap();
parameterMap.add("scope", "shared");
parameterMap.add("output", "service-name,state");
invocation.parameters(parameterMap).execute();
boolean sharedServiceStarted = false;
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
for (Map<String, String> map : list) {
sharedServiceStarted = false;
String state = map.get("STATE");
if ("RUNNING".equalsIgnoreCase(state)) {
sharedServiceStarted = true;
} else {
break;
}
}
// check if the shared services are started.
Assert.assertTrue(sharedServiceStarted);
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class SharedAndExternalServiceTest method createSharedAndExternalServices.
private void createSharedAndExternalServices(String ipAddress_DAS) {
System.out.println("################### Trying to Create Shared Service #######################");
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
// Create external service of type Database
// asadmin create-external-service --servicetype=Database --configuration ip-address=127.0.0.1:databasename=sun-appserv-samples:port=1527:user=APP:password=APP:host=127.0.0.1:classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource my-external-db-service
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("create-external-service", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("servicetype", "Database");
parameterMap.add("configuration", "ip-address=" + ipAddress_DAS + ":databasename=sun-appserv-samples:connectionAttributes=;'create=true':port=1527:user=APP:password=APP:host=" + ipAddress_DAS + ":classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource");
// parameterMap.add("configuration", "ip-address=127.0.0.1:databasename=${com.sun.aas.installRoot}/databases/sun-appserv-samples:port=1527:user=APP:password=APP:connectionAttributes=;'create\\=true':host=127.0.0.1:classname=org.apache.derby.jdbc.EmbeddedXADataSource:resourcetype=javax.sql.XADataSource");
parameterMap.add("DEFAULT", "my-external-db-service");
invocation.parameters(parameterMap).execute();
Assert.assertFalse(report.hasFailures());
/*
//Create external service of type Database
// asadmin create-external-service --servicetype=Database --configuration ip-address=127.0.0.1:databasename=sun-appserv-samples:port=1527:user=APP:password=APP:host=127.0.0.1:classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource my-external-db-service
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "Database");
parameterMap.add("configuration", "ip-address=127.0.0.1:databasename=sun-appserv-samples:port=1527:user=APP:password=APP:host=127.0.0.1:classname=org.apache.derby.jdbc.ClientXADataSource:resourcetype=javax.sql.XADataSource");
//parameterMap.add("configuration", "ip-address=127.0.0.1:databasename=${com.sun.aas.installRoot}/databases/sun-appserv-samples:port=1527:user=APP:password=APP:connectionAttributes=;'create\\=true':host=127.0.0.1:classname=org.apache.derby.jdbc.EmbeddedXADataSource:resourcetype=javax.sql.XADataSource");
parameterMap.add("DEFAULT", "my-external-db-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created external service 'my-external-db-service' :" + !report.hasFailures());
*/
Assert.assertFalse(report.hasFailures());
// Create shared service of type LB
// asadmin create-shared-service --characteristics service-type=LB --configuration http-port=50080:https-port=50081:ssl-enabled=true --servicetype LB my-shared-lb-service
invocation = commandRunner.getCommandInvocation("create-shared-service", report);
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "LB");
parameterMap.add("characteristics", "service-type=LB");
parameterMap.add("configuration", "http-port=50080:https-port=50081:ssl-enabled=true");
parameterMap.add("DEFAULT", "my-shared-lb-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-lb-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
{
// List the services and check the status of both the services - it should be 'RUNNING'
invocation = commandRunner.getCommandInvocation("list-services", report);
parameterMap = new ParameterMap();
parameterMap.add("scope", "shared");
parameterMap.add("output", "service-name,state");
invocation.parameters(parameterMap).execute();
boolean sharedServiceStarted = false;
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
for (Map<String, String> map : list) {
sharedServiceStarted = false;
String state = map.get("STATE");
if ("RUNNING".equalsIgnoreCase(state)) {
sharedServiceStarted = true;
} else {
break;
}
}
// check if the shared services are started.
Assert.assertTrue(sharedServiceStarted);
}
}
Aggregations