~ubuntu-branches/debian/sid/nordugrid-arc/sid

« back to all changes in this revision

Viewing changes to .pc/nordugrid-arc-xmlns.patch/src/hed/acc/JobDescriptionParser/test/ARCJSDLParserTest.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121213164131-0fumka0jar8mxm07
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifdef HAVE_CONFIG_H
2
 
#include <config.h>
3
 
#endif
4
 
 
5
 
#include <string>
6
 
 
7
 
#include <cppunit/extensions/HelperMacros.h>
8
 
 
9
 
#include <arc/StringConv.h>
10
 
#include <arc/XMLNode.h>
11
 
#include <arc/client/JobDescription.h>
12
 
 
13
 
#include "../ARCJSDLParser.h"
14
 
 
15
 
 
16
 
class ARCJSDLParserTest
17
 
  : public CppUnit::TestFixture {
18
 
 
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();
33
 
 
34
 
public:
35
 
  ARCJSDLParserTest():PARSER((Arc::PluginArgument*)NULL) {}
36
 
 
37
 
  void setUp();
38
 
  void tearDown();
39
 
  void TestExecutable();
40
 
  void TestInputOutputError();
41
 
  void TestInputFileClientStageable();
42
 
  void TestInputFileServiceStageable();
43
 
  void TestOutputFileClientStageable();
44
 
  void TestOutputFileServiceStageable();
45
 
  void TestURIOptionsInput();
46
 
  void TestURIOptionsOutput();
47
 
  void TestQueue();
48
 
  void TestDryRun();
49
 
  void TestPOSIXCompliance();
50
 
  void TestHPCCompliance();
51
 
 
52
 
private:
53
 
  Arc::JobDescription INJOB;
54
 
  std::list<Arc::JobDescription> OUTJOBS;
55
 
  Arc::ARCJSDLParser PARSER;
56
 
 
57
 
  std::string MESSAGE;
58
 
};
59
 
 
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()) {
63
 
      os << ", ";
64
 
    }
65
 
    os << "\"" << *it << "\"";
66
 
  }
67
 
 
68
 
  return os;
69
 
}
70
 
 
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");
76
 
}
77
 
 
78
 
void ARCJSDLParserTest::tearDown() {
79
 
}
80
 
 
81
 
void ARCJSDLParserTest::TestExecutable() {
82
 
  MESSAGE = "Error parsing executable related attributes.";
83
 
 
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());
88
 
 
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);
91
 
}
92
 
 
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";
98
 
 
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());
103
 
 
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);
107
 
}
108
 
 
109
 
/** Client stageable input file */
110
 
void ARCJSDLParserTest::TestInputFileClientStageable() {
111
 
  INJOB.DataStaging.InputFiles.clear();
112
 
  MESSAGE = "Error parsing TestInputFileClientStageable data staging type.";
113
 
 
114
 
  Arc::InputFileType file;
115
 
  file.Name = "TestInputFileClientStageable";
116
 
  file.Sources.push_back(Arc::URL(file.Name));
117
 
  INJOB.DataStaging.InputFiles.push_back(file);
118
 
 
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());
123
 
 
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());
128
 
}
129
 
 
130
 
/** Service stageable input file */
131
 
void ARCJSDLParserTest::TestInputFileServiceStageable() {
132
 
  INJOB.DataStaging.InputFiles.clear();
133
 
  MESSAGE = "Error parsing TestInputFileServiceStageable data staging type.";
134
 
 
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);
140
 
 
141
 
  CPPUNIT_ASSERT(INJOB.DataStaging.InputFiles.size() == 1);
142
 
  CPPUNIT_ASSERT(INJOB.DataStaging.InputFiles.front().Sources.size() == 1 && INJOB.DataStaging.InputFiles.front().Sources.front());
143
 
 
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());
148
 
 
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());
153
 
}
154
 
 
155
 
/** Client stageable output file */
156
 
void ARCJSDLParserTest::TestOutputFileClientStageable() {
157
 
  INJOB.DataStaging.OutputFiles.clear();
158
 
  MESSAGE = "Error parsing TestOutputFileClientStageable data staging type.";
159
 
 
160
 
  Arc::OutputFileType file;
161
 
  file.Name = "TestOutputFileClientStageable";
162
 
  INJOB.DataStaging.OutputFiles.push_back(file);
163
 
 
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());
168
 
 
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);
171
 
}
172
 
 
173
 
/** Service stageable output file */
174
 
void ARCJSDLParserTest::TestOutputFileServiceStageable() {
175
 
  INJOB.DataStaging.OutputFiles.clear();
176
 
  MESSAGE = "Error parsing TestOutputFileServiceStageable data staging type.";
177
 
 
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);
182
 
 
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());
187
 
 
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());
192
 
}
193
 
 
194
 
void ARCJSDLParserTest::TestURIOptionsInput() {
195
 
  std::string jsdl = "<?xml version=\"1.0\"?>"
196
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
197
 
  "<JobDescription>"
198
 
    "<Application>"
199
 
      "<posix-jsdl:POSIXApplication>"
200
 
      "<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
201
 
      "</posix-jsdl:POSIXApplication>"
202
 
    "</Application>"
203
 
    "<DataStaging>"
204
 
      "<FileName>test.file</FileName>"
205
 
      "<Source>"
206
 
        "<URI>gsiftp://example.com/test.file</URI>"
207
 
        "<URIOption>threads=5</URIOption>"
208
 
      "</Source>"
209
 
    "</DataStaging>"
210
 
  "</JobDescription>"
211
 
"</JobDefinition>";
212
 
 
213
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
214
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
215
 
 
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"));
221
 
}
222
 
 
223
 
void ARCJSDLParserTest::TestURIOptionsOutput() {
224
 
  std::string jsdl = "<?xml version=\"1.0\"?>"
225
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
226
 
  "<JobDescription>"
227
 
    "<Application>"
228
 
      "<posix-jsdl:POSIXApplication>"
229
 
      "<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
230
 
      "</posix-jsdl:POSIXApplication>"
231
 
    "</Application>"
232
 
    "<DataStaging>"
233
 
      "<FileName>test.file</FileName>"
234
 
      "<Target>"
235
 
        "<URI>rls://example.com/test.file</URI>"
236
 
        "<URIOption>checksum=md5</URIOption>"
237
 
        "<Location>"
238
 
          "<URI>gsiftp://example.com/test.file</URI>"
239
 
          "<URIOption>threads=5</URIOption>"
240
 
        "</Location>"
241
 
        "<Location>"
242
 
          "<URI>gsiftp://example2.com/test.file</URI>"
243
 
          "<URIOption>threads=10</URIOption>"
244
 
        "</Location>"
245
 
      "</Target>"
246
 
    "</DataStaging>"
247
 
  "</JobDescription>"
248
 
"</JobDefinition>";
249
 
 
250
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
251
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
252
 
 
253
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.front().DataStaging.OutputFiles.size());
254
 
  const Arc::OutputFileType f(OUTJOBS.front().DataStaging.OutputFiles.front());
255
 
 
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"));
259
 
 
260
 
  const std::list<Arc::URLLocation> locations(f.Targets.front().Locations());
261
 
  CPPUNIT_ASSERT_EQUAL(2, (int)locations.size());
262
 
 
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"));
265
 
 
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"));
268
 
}
269
 
 
270
 
void ARCJSDLParserTest::TestQueue() {
271
 
  std::string jsdl = "<?xml version=\"1.0\"?>"
272
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
273
 
"<JobDescription>"
274
 
"<Application>"
275
 
"<posix-jsdl:POSIXApplication>"
276
 
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
277
 
"</posix-jsdl:POSIXApplication>"
278
 
"</Application>"
279
 
"<Resources>"
280
 
"<QueueName>q1</QueueName>"
281
 
"</Resources>"
282
 
"</JobDescription>"
283
 
"</JobDefinition>";
284
 
 
285
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
286
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
287
 
 
288
 
  CPPUNIT_ASSERT_EQUAL((std::string)"q1", OUTJOBS.front().Resources.QueueName);
289
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
290
 
 
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());
294
 
 
295
 
  CPPUNIT_ASSERT_EQUAL((std::string)"q1", OUTJOBS.front().Resources.QueueName);
296
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
297
 
 
298
 
  jsdl = "<?xml version=\"1.0\"?>"
299
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
300
 
"<JobDescription>"
301
 
"<Application>"
302
 
"<posix-jsdl:POSIXApplication>"
303
 
"<posix-jsdl:Executable>executable</posix-jsdl:Executable>"
304
 
"</posix-jsdl:POSIXApplication>"
305
 
"</Application>"
306
 
"<Resources>"
307
 
"<QueueName require=\"ne\">q1</QueueName>"
308
 
"</Resources>"
309
 
"</JobDescription>"
310
 
"</JobDefinition>";
311
 
 
312
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
313
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
314
 
 
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);
319
 
 
320
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
321
 
 
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());
325
 
 
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());
329
 
}
330
 
 
331
 
void ARCJSDLParserTest::TestDryRun() {
332
 
  std::string jsdl = "<?xml version=\"1.0\"?>"
333
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
334
 
"<JobDescription>"
335
 
"<Application>"
336
 
"<Executable>"
337
 
"<Path>executable</Path>"
338
 
"</Executable>"
339
 
"<DryRun>yes</DryRun>"
340
 
"</Application>"
341
 
"</JobDescription>"
342
 
"</JobDefinition>";
343
 
 
344
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
345
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
346
 
 
347
 
  CPPUNIT_ASSERT(OUTJOBS.front().Application.DryRun);
348
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
349
 
 
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());
353
 
 
354
 
  CPPUNIT_ASSERT(OUTJOBS.front().Application.DryRun);
355
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
356
 
 
357
 
  jsdl = "<?xml version=\"1.0\"?>"
358
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
359
 
"<JobDescription>"
360
 
"<Application>"
361
 
"<Executable>"
362
 
"<Path>executable</Path>"
363
 
"</Executable>"
364
 
"<DryRun>no</DryRun>"
365
 
"</Application>"
366
 
"</JobDescription>"
367
 
"</JobDefinition>";
368
 
 
369
 
  CPPUNIT_ASSERT(PARSER.Parse(jsdl, OUTJOBS));
370
 
  CPPUNIT_ASSERT_EQUAL(1, (int)OUTJOBS.size());
371
 
 
372
 
  CPPUNIT_ASSERT(!OUTJOBS.front().Application.DryRun);
373
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
374
 
 
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());
378
 
 
379
 
  CPPUNIT_ASSERT(!OUTJOBS.front().Application.DryRun);
380
 
  CPPUNIT_ASSERT_EQUAL(0, (int)OUTJOBS.front().GetAlternatives().size());
381
 
}
382
 
 
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.";
386
 
 
387
 
  const std::string posixJSDLStr = "<?xml version=\"1.0\"?>"
388
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
389
 
"<JobDescription>"
390
 
"<Application>"
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>"
409
 
"</Application>"
410
 
"</JobDescription>"
411
 
"</JobDefinition>";
412
 
 
413
 
  INJOB.Application.Input = "input";
414
 
  INJOB.Application.Output = "output";
415
 
  INJOB.Application.Error = "error";
416
 
 
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"));
420
 
 
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;
427
 
 
428
 
  CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(posixJSDLStr, OUTJOBS));
429
 
  CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
430
 
 
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);
437
 
 
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);
444
 
 
445
 
  std::string tempjobdesc;
446
 
  CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(OUTJOBS.front(), tempjobdesc, "nordugrid:jsdl"));
447
 
 
448
 
  Arc::XMLNode xmlArcJSDL(tempjobdesc);
449
 
  Arc::XMLNode pApp = xmlArcJSDL["JobDescription"]["Application"]["POSIXApplication"];
450
 
 
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"]);
459
 
 
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]);
466
 
 
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"]));
473
 
}
474
 
 
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.";
478
 
 
479
 
  const std::string hpcJSDLStr = "<?xml version=\"1.0\"?>"
480
 
"<JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\">"
481
 
"<JobDescription>"
482
 
"<Application>"
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>"
501
 
"</Application>"
502
 
"</JobDescription>"
503
 
"</JobDefinition>";
504
 
 
505
 
  INJOB.Application.Input = "input";
506
 
  INJOB.Application.Output = "output";
507
 
  INJOB.Application.Error = "error";
508
 
 
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"));
512
 
 
513
 
  CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.Parse(hpcJSDLStr, OUTJOBS));
514
 
  CPPUNIT_ASSERT_EQUAL_MESSAGE(MESSAGE, 1, (int)OUTJOBS.size());
515
 
 
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);
522
 
 
523
 
  std::string tempjobdesc;
524
 
  CPPUNIT_ASSERT_MESSAGE(MESSAGE, PARSER.UnParse(OUTJOBS.front(), tempjobdesc, "nordugrid:jsdl"));
525
 
 
526
 
  Arc::XMLNode xmlArcJSDL(tempjobdesc);
527
 
  Arc::XMLNode pApp = xmlArcJSDL["JobDescription"]["Application"]["HPCProfileApplication"];
528
 
 
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"]);
537
 
 
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]);
544
 
}
545
 
 
546
 
CPPUNIT_TEST_SUITE_REGISTRATION(ARCJSDLParserTest);