7
#include <cppunit/extensions/HelperMacros.h>
9
#include <arc/StringConv.h>
10
#include <arc/XMLNode.h>
11
#include <arc/client/JobDescription.h>
13
#include "../ARCJSDLParser.h"
16
class ARCJSDLParserTest
17
: public CppUnit::TestFixture {
19
CPPUNIT_TEST_SUITE(ARCJSDLParserTest);
20
CPPUNIT_TEST(TestExecutable);
21
CPPUNIT_TEST(TestInputOutputError);
22
CPPUNIT_TEST(TestInputFileClientStageable);
23
CPPUNIT_TEST(TestInputFileServiceStageable);
24
CPPUNIT_TEST(TestOutputFileClientStageable);
25
CPPUNIT_TEST(TestOutputFileServiceStageable);
26
CPPUNIT_TEST(TestURIOptionsInput);
27
CPPUNIT_TEST(TestURIOptionsOutput);
28
CPPUNIT_TEST(TestQueue);
29
CPPUNIT_TEST(TestDryRun);
30
CPPUNIT_TEST(TestPOSIXCompliance);
31
CPPUNIT_TEST(TestHPCCompliance);
32
CPPUNIT_TEST_SUITE_END();
35
ARCJSDLParserTest():PARSER((Arc::PluginArgument*)NULL) {}
39
void TestExecutable();
40
void TestInputOutputError();
41
void TestInputFileClientStageable();
42
void TestInputFileServiceStageable();
43
void TestOutputFileClientStageable();
44
void TestOutputFileServiceStageable();
45
void TestURIOptionsInput();
46
void TestURIOptionsOutput();
49
void TestPOSIXCompliance();
50
void TestHPCCompliance();
53
Arc::JobDescription INJOB;
54
std::list<Arc::JobDescription> OUTJOBS;
55
Arc::ARCJSDLParser PARSER;
60
std::ostream& operator<<(std::ostream& os, const std::list<std::string>& strings) {
61
for (std::list<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) {
62
if (it != strings.begin()) {
65
os << "\"" << *it << "\"";
71
void ARCJSDLParserTest::setUp() {
72
INJOB.Application.Executable.Path = "executable";
73
INJOB.Application.Executable.Argument.push_back("arg1");
74
INJOB.Application.Executable.Argument.push_back("arg2");
75
INJOB.Application.Executable.Argument.push_back("arg3");
78
void ARCJSDLParserTest::tearDown() {
81
void ARCJSDLParserTest::TestExecutable() {
82
MESSAGE = "Error parsing executable related attributes.";
84
std::string tempjobdesc;
85
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
86
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
87
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
89
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.Application.Executable.Path, OUTJOBS.front().Application.Executable.Path);
90
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.Application.Executable.Argument, OUTJOBS.front().Application.Executable.Argument);
93
void ARCJSDLParserTest::TestInputOutputError() {
94
MESSAGE = "Error parsing standard input/output/error attributes.";
95
INJOB.Application.Input = "input-file";
96
INJOB.Application.Output = "output-file";
97
INJOB.Application.Error = "error-file";
99
std::string tempjobdesc;
100
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
101
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
102
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
104
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.Application.Input, OUTJOBS.front().Application.Input);
105
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.Application.Output, OUTJOBS.front().Application.Output);
106
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.Application.Error, OUTJOBS.front().Application.Error);
109
/** Client stageable input file */
110
void ARCJSDLParserTest::TestInputFileClientStageable() {
111
INJOB.DataStaging.InputFiles.clear();
112
MESSAGE = "Error parsing TestInputFileClientStageable data staging type.";
114
Arc::InputFileType file;
115
file.Name = "TestInputFileClientStageable";
116
file.Sources.push_back(Arc::URL(file.Name));
117
INJOB.DataStaging.InputFiles.push_back(file);
119
std::string tempjobdesc;
120
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
121
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
122
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
124
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.InputFiles.size() == 1);
125
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.InputFiles.front().Name, OUTJOBS.front().DataStaging.InputFiles.front().Name);
126
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.InputFiles.front().Sources.size() == 1 && OUTJOBS.front().DataStaging.InputFiles.front().Sources.front());
127
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.InputFiles.front().Sources.front(), OUTJOBS.front().DataStaging.InputFiles.front().Sources.front());
130
/** Service stageable input file */
131
void ARCJSDLParserTest::TestInputFileServiceStageable() {
132
INJOB.DataStaging.InputFiles.clear();
133
MESSAGE = "Error parsing TestInputFileServiceStageable data staging type.";
135
Arc::InputFileType file;
136
file.Name = "TestInputFileServiceStageable";
137
file.Sources.push_back(Arc::URL("http://example.com/" + file.Name));
138
file.IsExecutable = false;
139
INJOB.DataStaging.InputFiles.push_back(file);
141
CPPUNIT_ASSERT(INJOB.DataStaging.InputFiles.size() == 1);
142
CPPUNIT_ASSERT(INJOB.DataStaging.InputFiles.front().Sources.size() == 1 && INJOB.DataStaging.InputFiles.front().Sources.front());
144
std::string tempjobdesc;
145
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
146
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
147
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
149
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.InputFiles.size() == 1);
150
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.InputFiles.front().Name, OUTJOBS.front().DataStaging.InputFiles.front().Name);
151
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.InputFiles.front().Sources.size() == 1 && OUTJOBS.front().DataStaging.InputFiles.front().Sources.front());
152
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.InputFiles.front().Sources.front(), OUTJOBS.front().DataStaging.InputFiles.front().Sources.front());
155
/** Client stageable output file */
156
void ARCJSDLParserTest::TestOutputFileClientStageable() {
157
INJOB.DataStaging.OutputFiles.clear();
158
MESSAGE = "Error parsing TestOutputFileClientStageable data staging type.";
160
Arc::OutputFileType file;
161
file.Name = "TestOutputFileClientStageable";
162
INJOB.DataStaging.OutputFiles.push_back(file);
164
std::string tempjobdesc;
165
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
166
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
167
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
169
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.OutputFiles.size() == 1);
170
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.OutputFiles.front().Name, OUTJOBS.front().DataStaging.OutputFiles.front().Name);
173
/** Service stageable output file */
174
void ARCJSDLParserTest::TestOutputFileServiceStageable() {
175
INJOB.DataStaging.OutputFiles.clear();
176
MESSAGE = "Error parsing TestOutputFileServiceStageable data staging type.";
178
Arc::OutputFileType file;
179
file.Name = "TestOutputFileServiceStageable";
180
file.Targets.push_back(Arc::URL("http://example.com/" + file.Name));
181
INJOB.DataStaging.OutputFiles.push_back(file);
183
std::string tempjobdesc;
184
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(INJOB, tempjobdesc, "nordugrid:jsdl"));
185
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(tempjobdesc, OUTJOBS));
186
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
188
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.OutputFiles.size() == 1);
189
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.OutputFiles.front().Name, OUTJOBS.front().DataStaging.OutputFiles.front().Name);
190
CPPUNIT_ASSERT_MESSAGE(MESSAGE, OUTJOBS.front().DataStaging.OutputFiles.front().Targets.size() == 1 && OUTJOBS.front().DataStaging.OutputFiles.front().Targets.front());
191
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, INJOB.DataStaging.OutputFiles.front().Targets.front(), OUTJOBS.front().DataStaging.OutputFiles.front().Targets.front());
194
void ARCJSDLParserTest::TestURIOptionsInput() {
195
std::string jsdl = "<?xml version=\"1.0\"?>"
196
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
199
"<posix-jsdl:POSIXApplication>"
200
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
201
"</posix-jsdl:POSIXApplication>"
204
"<FileName>test.file</FileName>"
206
"<URI>gsiftp://example.com/test.file</URI>"
207
"<URIOption>threads=5</URIOption>"
213
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
214
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
216
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.front().DataStaging.InputFiles.size());
217
const Arc::InputFileType f(OUTJOBS.front().DataStaging.InputFiles.front());
218
CPPUNIT_ASSERT_EQUAL(std::string("test.file"), f.Name);
219
CPPUNIT_ASSERT_EQUAL(std::string("gsiftp://example.com:2811/test.file"), f.Sources.front().str());
220
CPPUNIT_ASSERT_EQUAL(std::string("5"), f.Sources.front().Option("threads"));
223
void ARCJSDLParserTest::TestURIOptionsOutput() {
224
std::string jsdl = "<?xml version=\"1.0\"?>"
225
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
228
"<posix-jsdl:POSIXApplication>"
229
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
230
"</posix-jsdl:POSIXApplication>"
233
"<FileName>test.file</FileName>"
235
"<URI>rls://example.com/test.file</URI>"
236
"<URIOption>checksum=md5</URIOption>"
238
"<URI>gsiftp://example.com/test.file</URI>"
239
"<URIOption>threads=5</URIOption>"
242
"<URI>gsiftp://example2.com/test.file</URI>"
243
"<URIOption>threads=10</URIOption>"
250
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
251
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
253
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.front().DataStaging.OutputFiles.size());
254
const Arc::OutputFileType f(OUTJOBS.front().DataStaging.OutputFiles.front());
256
CPPUNIT_ASSERT_EQUAL(std::string("test.file"), f.Name);
257
CPPUNIT_ASSERT_EQUAL(std::string("rls://example.com:39281/test.file"), f.Targets.front().str());
258
CPPUNIT_ASSERT_EQUAL(std::string("md5"), f.Targets.front().Option("checksum"));
260
const std::list<Arc::URLLocation> locations(f.Targets.front().Locations());
261
CPPUNIT_ASSERT_EQUAL(2, (int)locations.size());
263
CPPUNIT_ASSERT_EQUAL(std::string("gsiftp://example.com:2811/test.file"), locations.front().str());
264
CPPUNIT_ASSERT_EQUAL(std::string("5"), locations.front().Option("threads"));
266
CPPUNIT_ASSERT_EQUAL(std::string("gsiftp://example2.com:2811/test.file"), locations.back().str());
267
CPPUNIT_ASSERT_EQUAL(std::string("10"), locations.back().Option("threads"));
270
void ARCJSDLParserTest::TestQueue() {
271
std::string jsdl = "<?xml version=\"1.0\"?>"
272
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
275
"<posix-jsdl:POSIXApplication>"
276
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
277
"</posix-jsdl:POSIXApplication>"
280
"<QueueName>q1</QueueName>"
285
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
286
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
288
CPPUNIT_ASSERT_EQUAL((std::string)"q1", OUTJOBS.front().Resources.QueueName);
289
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
291
CPPUNIT_ASSERT(PARSER.UnParse(OUTJOBS.front(), jsdl, "nordugrid:jsdl"));
292
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
293
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
295
CPPUNIT_ASSERT_EQUAL((std::string)"q1", OUTJOBS.front().Resources.QueueName);
296
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
298
jsdl = "<?xml version=\"1.0\"?>"
299
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
302
"<posix-jsdl:POSIXApplication>"
303
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
304
"</posix-jsdl:POSIXApplication>"
307
"<QueueName require=\"ne\">q1</QueueName>"
312
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
313
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
315
std::map<std::string, std::string>::const_iterator itAttribute;
316
itAttribute = OUTJOBS.front().OtherAttributes.find("nordugrid:broker;reject_queue");
317
CPPUNIT_ASSERT(OUTJOBS.front().OtherAttributes.end() != itAttribute);
318
CPPUNIT_ASSERT_EQUAL((std::string)"q1", itAttribute->second);
320
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
322
CPPUNIT_ASSERT(PARSER.UnParse(OUTJOBS.front(), jsdl, "nordugrid:jsdl"));
323
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
324
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
326
itAttribute = OUTJOBS.front().OtherAttributes.find("nordugrid:broker;reject_queue");
327
CPPUNIT_ASSERT(OUTJOBS.front().OtherAttributes.end() == itAttribute);
328
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
331
void ARCJSDLParserTest::TestDryRun() {
332
std::string jsdl = "<?xml version=\"1.0\"?>"
333
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
337
"<Path>executable</Path>"
339
"<DryRun>yes</DryRun>"
344
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
345
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
347
CPPUNIT_ASSERT(OUTJOBS.front().Application.DryRun);
348
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
350
CPPUNIT_ASSERT(PARSER.UnParse(OUTJOBS.front(), jsdl, "nordugrid:jsdl"));
351
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
352
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
354
CPPUNIT_ASSERT(OUTJOBS.front().Application.DryRun);
355
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
357
jsdl = "<?xml version=\"1.0\"?>"
358
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
362
"<Path>executable</Path>"
364
"<DryRun>no</DryRun>"
369
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
370
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
372
CPPUNIT_ASSERT(!OUTJOBS.front().Application.DryRun);
373
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
375
CPPUNIT_ASSERT(PARSER.UnParse(OUTJOBS.front(), jsdl, "nordugrid:jsdl"));
376
CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
377
CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
379
CPPUNIT_ASSERT(!OUTJOBS.front().Application.DryRun);
380
CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
383
void ARCJSDLParserTest::TestPOSIXCompliance() {
384
/** Testing compliance with GFD 56 - the POSIX extension **/
385
MESSAGE = "Error: The parser does not comply with the JDSL POSIX specification.";
387
const std::string posixJSDLStr = "<?xml version=\"1.0\"?>"
388
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
391
"<posix-jsdl:POSIXApplication>"
392
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
393
"<posix-jsdl:Argument>arg1</posix-jsdl:Argument>"
394
"<posix-jsdl:Argument>arg2</posix-jsdl:Argument>"
395
"<posix-jsdl:Argument>arg3</posix-jsdl:Argument>"
396
"<posix-jsdl:Input>input</posix-jsdl:Input>"
397
"<posix-jsdl:Output>output</posix-jsdl:Output>"
398
"<posix-jsdl:Error>error</posix-jsdl:Error>"
399
"<posix-jsdl:Environment name=\"var1\">value1</posix-jsdl:Environment>"
400
"<posix-jsdl:Environment name=\"var2\">value2</posix-jsdl:Environment>"
401
"<posix-jsdl:Environment name=\"var3\">value3</posix-jsdl:Environment>"
402
"<posix-jsdl:WallTimeLimit>50</posix-jsdl:WallTimeLimit>"
403
"<posix-jsdl:MemoryLimit>104857600</posix-jsdl:MemoryLimit>"
404
"<posix-jsdl:CPUTimeLimit>110</posix-jsdl:CPUTimeLimit>"
405
"<posix-jsdl:ProcessCountLimit>2</posix-jsdl:ProcessCountLimit>"
406
"<posix-jsdl:VirtualMemoryLimit>500</posix-jsdl:VirtualMemoryLimit>"
407
"<posix-jsdl:ThreadCountLimit>7</posix-jsdl:ThreadCountLimit>"
408
"</posix-jsdl:POSIXApplication>"
413
INJOB.Application.Input = "input";
414
INJOB.Application.Output = "output";
415
INJOB.Application.Error = "error";
417
INJOB.Application.Environment.push_back(std::make_pair("var1", "value1"));
418
INJOB.Application.Environment.push_back(std::make_pair("var2", "value2"));
419
INJOB.Application.Environment.push_back(std::make_pair("var3", "value3"));
421
INJOB.Resources.TotalWallTime = 50;
422
INJOB.Resources.IndividualPhysicalMemory = 100;
423
INJOB.Resources.TotalCPUTime = 110;
424
INJOB.Resources.SlotRequirement.NumberOfSlots = 2;
425
INJOB.Resources.IndividualVirtualMemory = 500;
426
INJOB.Resources.ParallelEnvironment.ThreadsPerProcess = 7;
428
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(posixJSDLStr, OUTJOBS));
429
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
431
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Executable.Path, OUTJOBS.front().Application.Executable.Path);
432
CPPUNIT_ASSERT_MESSAGE("POSIX compliance failure", INJOB.Application.Executable.Argument == OUTJOBS.front().Application.Executable.Argument);
433
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Input, OUTJOBS.front().Application.Input);
434
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Output, OUTJOBS.front().Application.Output);
435
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Error, OUTJOBS.front().Application.Error);
436
CPPUNIT_ASSERT_MESSAGE("POSIX compliance failure", INJOB.Application.Environment == OUTJOBS.front().Application.Environment);
438
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.TotalWallTime.range.max, OUTJOBS.front().Resources.TotalWallTime.range.max);
439
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.IndividualPhysicalMemory.max, OUTJOBS.front().Resources.IndividualPhysicalMemory.max);
440
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.TotalCPUTime.range.max, OUTJOBS.front().Resources.TotalCPUTime.range.max);
441
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.SlotRequirement.NumberOfSlots, OUTJOBS.front().Resources.SlotRequirement.NumberOfSlots);
442
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.IndividualVirtualMemory.max, OUTJOBS.front().Resources.IndividualVirtualMemory.max);
443
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.ParallelEnvironment.ThreadsPerProcess, OUTJOBS.front().Resources.ParallelEnvironment.ThreadsPerProcess);
445
std::string tempjobdesc;
446
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(OUTJOBS.front(), tempjobdesc, "nordugrid:jsdl"));
448
Arc::XMLNode xmlArcJSDL(tempjobdesc);
449
Arc::XMLNode pApp = xmlArcJSDL["JobDescription"]["Application"]["POSIXApplication"];
451
CPPUNIT_ASSERT_MESSAGE("POSIX compliance failure", pApp);
452
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Executable.Path, (std::string)pApp["Executable"]);
453
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"arg1", (std::string)pApp["Argument"][0]);
454
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"arg2", (std::string)pApp["Argument"][1]);
455
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"arg3", (std::string)pApp["Argument"][2]);
456
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Input, (std::string)pApp["Input"]);
457
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Output, (std::string)pApp["Output"]);
458
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Application.Error, (std::string)pApp["Error"]);
460
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"var1", (std::string)pApp["Environment"][0].Attribute("name"));
461
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"value1", (std::string)pApp["Environment"][0]);
462
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"var2", (std::string)pApp["Environment"][1].Attribute("name"));
463
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"value2", (std::string)pApp["Environment"][1]);
464
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"var3", (std::string)pApp["Environment"][2].Attribute("name"));
465
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", (std::string)"value3", (std::string)pApp["Environment"][2]);
467
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.TotalWallTime.range.max, Arc::stringto<int>(pApp["WallTimeLimit"]));
468
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.IndividualPhysicalMemory.max, (int)(Arc::stringto<long long>(pApp["MemoryLimit"])/(1024*1024)));
469
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.TotalCPUTime.range.max, Arc::stringto<int>(pApp["CPUTimeLimit"]));
470
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.SlotRequirement.NumberOfSlots, Arc::stringto<int>(pApp["ProcessCountLimit"]));
471
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.IndividualVirtualMemory.max, Arc::stringto<int>(pApp["VirtualMemoryLimit"]));
472
CPPUNIT_ASSERT_EQUAL_MESSAGE("POSIX compliance failure", INJOB.Resources.ParallelEnvironment.ThreadsPerProcess, Arc::stringto<int>(pApp["ThreadCountLimit"]));
475
void ARCJSDLParserTest::TestHPCCompliance() {
476
/** Testing compliance with GFD 111 **/
477
MESSAGE = "Error: The parser does not comply with the JSDL HPC Profile Application Extension specification.";
479
const std::string hpcJSDLStr = "<?xml version=\"1.0\"?>"
480
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
483
"<HPC-jsdl:HPCProfileApplication>"
484
"<HPC-jsdl:Executable>executable</HPC-jsdl:Executable>"
485
"<HPC-jsdl:Argument>arg1</HPC-jsdl:Argument>"
486
"<HPC-jsdl:Argument>arg2</HPC-jsdl:Argument>"
487
"<HPC-jsdl:Argument>arg3</HPC-jsdl:Argument>"
488
"<HPC-jsdl:Input>input</HPC-jsdl:Input>"
489
"<HPC-jsdl:Output>output</HPC-jsdl:Output>"
490
"<HPC-jsdl:Error>error</HPC-jsdl:Error>"
491
"<HPC-jsdl:Environment name=\"var1\">value1</HPC-jsdl:Environment>"
492
"<HPC-jsdl:Environment name=\"var2\">value2</HPC-jsdl:Environment>"
493
"<HPC-jsdl:Environment name=\"var3\">value3</HPC-jsdl:Environment>"
494
"<HPC-jsdl:WallTimeLimit>50</HPC-jsdl:WallTimeLimit>"
495
"<HPC-jsdl:MemoryLimit>100</HPC-jsdl:MemoryLimit>"
496
"<HPC-jsdl:CPUTimeLimit>110</HPC-jsdl:CPUTimeLimit>"
497
"<HPC-jsdl:ProcessCountLimit>2</HPC-jsdl:ProcessCountLimit>"
498
"<HPC-jsdl:VirtualMemoryLimit>500</HPC-jsdl:VirtualMemoryLimit>"
499
"<HPC-jsdl:ThreadCountLimit>7</HPC-jsdl:ThreadCountLimit>"
500
"</HPC-jsdl:HPCProfileApplication>"
505
INJOB.Application.Input = "input";
506
INJOB.Application.Output = "output";
507
INJOB.Application.Error = "error";
509
INJOB.Application.Environment.push_back(std::make_pair("var1", "value1"));
510
INJOB.Application.Environment.push_back(std::make_pair("var2", "value2"));
511
INJOB.Application.Environment.push_back(std::make_pair("var3", "value3"));
513
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(hpcJSDLStr, OUTJOBS));
514
CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
516
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Executable.Path, OUTJOBS.front().Application.Executable.Path);
517
CPPUNIT_ASSERT_MESSAGE("HPC compliance failure", INJOB.Application.Executable.Argument == OUTJOBS.front().Application.Executable.Argument);
518
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Input, OUTJOBS.front().Application.Input);
519
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Output, OUTJOBS.front().Application.Output);
520
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Error, OUTJOBS.front().Application.Error);
521
CPPUNIT_ASSERT_MESSAGE("HPC compliance failure", INJOB.Application.Environment == OUTJOBS.front().Application.Environment);
523
std::string tempjobdesc;
524
CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(OUTJOBS.front(), tempjobdesc, "nordugrid:jsdl"));
526
Arc::XMLNode xmlArcJSDL(tempjobdesc);
527
Arc::XMLNode pApp = xmlArcJSDL["JobDescription"]["Application"]["HPCProfileApplication"];
529
CPPUNIT_ASSERT_MESSAGE("HPC compliance failure", pApp);
530
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Executable.Path, (std::string)pApp["Executable"]);
531
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"arg1", (std::string)pApp["Argument"][0]);
532
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"arg2", (std::string)pApp["Argument"][1]);
533
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"arg3", (std::string)pApp["Argument"][2]);
534
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Input, (std::string)pApp["Input"]);
535
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Output, (std::string)pApp["Output"]);
536
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", INJOB.Application.Error, (std::string)pApp["Error"]);
538
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"var1", (std::string)pApp["Environment"][0].Attribute("name"));
539
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"value1", (std::string)pApp["Environment"][0]);
540
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"var2", (std::string)pApp["Environment"][1].Attribute("name"));
541
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"value2", (std::string)pApp["Environment"][1]);
542
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"var3", (std::string)pApp["Environment"][2].Attribute("name"));
543
CPPUNIT_ASSERT_EQUAL_MESSAGE("HPC compliance failure", (std::string)"value3", (std::string)pApp["Environment"][2]);
546
CPPUNIT_TEST_SUITE_REGISTRATION(ARCJSDLParserTest);