use of org.gridlab.gat.resources.JobDescription in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobStateConsistency.
private AdaptorTestResultEntry submitJobStateConsistency(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/sleep");
sd.setArguments("2");
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobStateMetricListener listener = new JobStateMetricListener(this);
long start = System.currentTimeMillis();
try {
broker.submitJob(jd, listener, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(listener.getException() == null, (stop - start), listener.getException());
}
use of org.gridlab.gat.resources.JobDescription in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobEnvironment.
private AdaptorTestResultEntry submitJobEnvironment(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
Map<String, Object> env = new HashMap<String, Object>();
env.put("JAVAGAT_TEST_KEY", "javagat-test-value");
sd.setEnvironment(env);
sd.setExecutable("/usr/bin/env");
try {
sd.setStdout(GAT.createFile(gatContext, preferences, "stdout"));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long start = System.currentTimeMillis();
Job job;
try {
job = broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
try {
Map<String, Object> info = job.getInfo();
Throwable ex = (Throwable) info.get("poststage.exception");
if (ex != null) {
return new AdaptorTestResultEntry(false, 0L, ex);
}
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long stop = System.currentTimeMillis();
boolean success = false;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new java.io.FileInputStream("stdout")));
while (true) {
String result = reader.readLine();
if (result == null) {
break;
}
if (result.contains("JAVAGAT_TEST_KEY") && result.contains("javagat-test-value")) {
success = true;
}
}
reader.close();
} catch (Exception e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
return new AdaptorTestResultEntry(success, (stop - start), null);
}
use of org.gridlab.gat.resources.JobDescription in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobGetInfo.
private AdaptorTestResultEntry submitJobGetInfo(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/sleep");
sd.setArguments("2");
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
Job job = null;
Exception exception = null;
long start = System.currentTimeMillis();
try {
job = broker.submitJob(jd);
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
while (job.getState() != Job.JobState.STOPPED) {
Map<String, Object> info = null;
try {
info = job.getInfo();
} catch (GATInvocationException e) {
exception = e;
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// ignored
}
continue;
}
if (info == null) {
exception = new Exception("getInfo returns null");
} else {
if (!info.containsKey("state")) {
exception = new Exception("getInfo doesn't contain a key 'state'");
}
if (!info.containsKey("hostname")) {
exception = new Exception("getInfo doesn't contain a key 'hostname'");
} else {
if (info.get("state").equals(Job.JobState.RUNNING) && info.get("hostname") == null) {
exception = new Exception("inconsistent getInfo: state=RUNNING, hostname=null");
}
}
if (!info.containsKey("submissiontime")) {
exception = new Exception("getInfo doesn't contain a key 'submissiontime'");
}
if (!info.containsKey("starttime")) {
exception = new Exception("getInfo doesn't contain a key 'starttime'");
}
if (!info.containsKey("stoptime")) {
exception = new Exception("getInfo doesn't contain a key 'stoptime'");
}
if (!info.containsKey("poststage.exception")) {
exception = new Exception("getInfo doesn't contain a key 'poststage.exception'");
}
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
exception = e;
}
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(exception == null, (stop - start), exception);
}
use of org.gridlab.gat.resources.JobDescription in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobParallel.
private AdaptorTestResultEntry submitJobParallel(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/echo");
sd.setArguments("test", "1", "2", "3");
try {
sd.setStdout(GAT.createFile(gatContext, preferences, "parallel-stdout"));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobDescription jd = new JobDescription(sd);
jd.setProcessCount(2);
jd.setResourceCount(1);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long start = System.currentTimeMillis();
try {
broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(true, (stop - start), null);
}
use of org.gridlab.gat.resources.JobDescription in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobStderr.
private AdaptorTestResultEntry submitJobStderr(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/ls");
sd.setArguments("floep");
try {
sd.setStderr(GAT.createFile(gatContext, preferences, "stderr"));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long start = System.currentTimeMillis();
Job job;
try {
job = broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
try {
Map<String, Object> info = job.getInfo();
Throwable ex = (Throwable) info.get("poststage.exception");
if (ex != null) {
return new AdaptorTestResultEntry(false, 0L, ex);
}
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long stop = System.currentTimeMillis();
String result;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new java.io.FileInputStream("stderr")));
result = reader.readLine();
reader.close();
} catch (Exception e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
return new AdaptorTestResultEntry(result != null && result.endsWith("floep: No such file or directory"), (stop - start), null);
}
Aggregations