use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class GlobalVariablesParserTest method testParseConfigTwoVars.
@Test
public void testParseConfigTwoVars() throws IOException {
GlobalVariablesParser.setConfigurationPath(GlobalVariablesParserTest.class.getResource("global_variables_two_vars.xml").toExternalForm());
GlobalVariablesParser.getInstance().reloadFilters();
List<Filter> filters = GlobalVariablesParser.getInstance().getLoadedFilters();
Assert.assertEquals(1, filters.size());
Assert.assertEquals(1, filters.get(0).getXpath().size());
Assert.assertEquals(".", filters.get(0).getXpath().get(0));
Assert.assertEquals(2, filters.get(0).getVariables().size());
Assert.assertEquals(new JobVariable("var1", "value1", "model1"), filters.get(0).getVariables().get(0));
Assert.assertEquals(new JobVariable("var2", "value2", "model2"), filters.get(0).getVariables().get(1));
GlobalVariablesData globalData = GlobalVariablesParser.getInstance().getVariablesFor(IOUtils.toString(GlobalVariablesParserTest.class.getResource("/org/ow2/proactive/scheduler/common/job/factories/job_no_variables.xml"), PASchedulerProperties.FILE_ENCODING.getValueAsString()));
;
Map<String, JobVariable> globalVariables = globalData.getVariables();
Assert.assertEquals(2, globalVariables.size());
Assert.assertEquals(new JobVariable("var1", "value1", "model1"), globalVariables.get("var1"));
Assert.assertEquals(new JobVariable("var2", "value2", "model2"), globalVariables.get("var2"));
Map<String, String> globalGI = globalData.getGenericInformation();
Assert.assertEquals(2, globalGI.size());
Assert.assertEquals("gi_value1", globalGI.get("gi1"));
Assert.assertEquals("gi_value2", globalGI.get("gi2"));
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class GlobalVariablesParserTest method testParseConfigOneFilterOK.
@Test
public void testParseConfigOneFilterOK() throws IOException {
GlobalVariablesParser.setConfigurationPath(GlobalVariablesParserTest.class.getResource("global_variables_one_filter.xml").toExternalForm());
GlobalVariablesParser.getInstance().reloadFilters();
List<Filter> filters = GlobalVariablesParser.getInstance().getLoadedFilters();
Assert.assertEquals(1, filters.size());
Assert.assertEquals(2, filters.get(0).getXpath().size());
Assert.assertEquals(2, filters.get(0).getVariables().size());
GlobalVariablesData globalData = GlobalVariablesParser.getInstance().getVariablesFor(IOUtils.toString(GlobalVariablesParserTest.class.getResource("/org/ow2/proactive/scheduler/common/job/factories/job_with_global_variables_and_gi.xml"), PASchedulerProperties.FILE_ENCODING.getValueAsString()));
Map<String, JobVariable> globalVariables = globalData.getVariables();
// As this job matches the xpath filters, it will return the configured variables
Assert.assertEquals(2, globalVariables.size());
Assert.assertEquals(new JobVariable("var1", "value1", "model1"), globalVariables.get("var1"));
Assert.assertEquals(new JobVariable("var2", "value2", "model2"), globalVariables.get("var2"));
Map<String, String> globalGI = globalData.getGenericInformation();
Assert.assertEquals(2, globalGI.size());
Assert.assertEquals("gi_value1", globalGI.get("gi1"));
Assert.assertEquals("gi_value2", globalGI.get("gi2"));
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class GetJobContentGeneratorTest method testReplaceVars.
@Test
public void testReplaceVars() throws IOException {
URL url = Resources.getResource("org/ow2/proactive/scheduler/common/job/factories/job_with_vars_and_info.xml");
String jobContent = Resources.toString(url, Charsets.UTF_8);
Map<String, JobVariable> vars = new HashMap<>();
vars.put("var", new JobVariable("var", "myvalue"));
final String newJobContent = generator.replaceVarsAndGenericInfo(jobContent, vars, Collections.emptyMap());
assertTrue(newJobContent.contains("<variables>"));
assertTrue(newJobContent.contains("myvalue"));
assertFalse(newJobContent.contains("<genericInformation>"));
assertNotEquals(jobContent, newJobContent);
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class SchedulerClientTest method testReSubmitJobReplaceVarValue.
@Test
public void testReSubmitJobReplaceVarValue() throws Exception {
ISchedulerClient client = clientInstance();
Job job = nodeClientJob("/functionaltests/descriptors/dataspace_client_node_push_delete.groovy", "/functionaltests/descriptors/dataspace_client_node_fork.groovy", null);
job.getVariables().put("originalVar", new JobVariable("originalVar", "originalValue"));
JobId jobId = submitJob(job, client);
Map<String, String> vars = new HashMap<>();
vars.put("originalVar", "newValue");
JobId jobId1 = client.reSubmit(jobId, vars, Collections.emptyMap(), null);
String jobContent1 = client.getJobContent(jobId1);
assertTrue(jobContent1.contains("<variables>"));
assertTrue(jobContent1.contains("originalVar"));
assertTrue(jobContent1.contains("newValue"));
assertFalse(jobContent1.contains("originalValue"));
assertFalse(jobContent1.contains("<genericInformation>"));
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class SchedulerClientTest method testSignals.
@Test(timeout = MAX_WAIT_TIME)
public void testSignals() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = nodeClientJob("/functionaltests/descriptors/register_service_with_signals.groovy", null, null);
// submit job with 'ready signal' and add variables
JobId jobId = submitJob(job, client);
JobInfo jobInfo;
// wait until 'ready_my_signal' signal is sent
do {
jobInfo = client.getJobInfo(jobId.toString());
Assert.assertNotNull(jobInfo);
Thread.sleep(1000);
} while (!jobInfo.getSignals().contains("ready_my_signal"));
Map<String, String> outpuVariables = new HashMap<>();
outpuVariables.put("name", "15");
// validate the job variables
List<JobVariable> jobVariables = client.validateJobSignal(jobId.value(), "my_signal", outpuVariables);
// add 'my_signal' signal
Set<String> signals = client.addJobSignal(jobId.value(), "my_signal", outpuVariables);
// wait until the job is finished
client.waitForJob(jobId.toString(), TimeUnit.MINUTES.toMillis(5));
Assert.assertFalse(signals.contains("ready_my_signal"));
Assert.assertTrue(signals.contains("my_signal"));
JobVariable nameJobVariable = jobVariables.stream().filter(jobVariable -> jobVariable.getName().equals("name")).findFirst().get();
Assert.assertNotNull(nameJobVariable);
Assert.assertEquals("15", nameJobVariable.getValue());
Assert.assertEquals("PA:Integer", nameJobVariable.getModel());
JobVariable secondJobVariable = jobVariables.stream().filter(jobVariable -> jobVariable.getName().equals("second")).findFirst().get();
Assert.assertNotNull(secondJobVariable);
Assert.assertEquals("15", secondJobVariable.getValue());
Assert.assertEquals("PA:Integer", secondJobVariable.getModel());
}
Aggregations