1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var CodeGradX = require('codegradxagent');
|
7 | var Agent = require('../codegradxvmauthor.js');
|
8 | var vmauthData = require('./vmauth-data.json');
|
9 |
|
10 | describe("CodeGradXVMauthorAgent process Batch", function () {
|
11 |
|
12 | it("should be loaded", function () {
|
13 | expect(Agent).toBeDefined();
|
14 | var agent = new CodeGradX.VMauthorAgent();
|
15 | expect(agent).toBeDefined();
|
16 | });
|
17 |
|
18 | function make_faildone (done) {
|
19 | return function faildone (reason) {
|
20 |
|
21 |
|
22 | fail(reason);
|
23 | done();
|
24 | };
|
25 | }
|
26 |
|
27 |
|
28 | var exercise1;
|
29 |
|
30 | it("should get hold of one exercise", function (done) {
|
31 | agent = new CodeGradX.VMauthorAgent();
|
32 | var faildone = make_faildone(done);
|
33 | var exerciseName = "org.example.li205.function.1";
|
34 | agent.process([
|
35 | "--user", vmauthData.login,
|
36 | "--password", vmauthData.password,
|
37 | "--update-credentials"
|
38 | ]).then(function (user) {
|
39 | expect(user).toBeDefined();
|
40 | user.getCampaign('example').then(function (campaign) {
|
41 | expect(campaign).toBeDefined();
|
42 | expect(campaign.name).toBe('example');
|
43 | campaign.getExercise(exerciseName).then(function (exercise) {
|
44 | expect(exercise).toBeDefined();
|
45 | exercise1 = exercise;
|
46 |
|
47 | done();
|
48 | }, faildone);
|
49 | }, faildone);
|
50 | }, faildone);
|
51 | }, 10*1000);
|
52 |
|
53 | it("initiate a batch then resume it", function (done) {
|
54 | agent = CodeGradX.getCurrentAgent();
|
55 | var faildone = make_faildone(done);
|
56 | function resumeBatch (batch) {
|
57 | expect(batch).toBeDefined();
|
58 |
|
59 |
|
60 | agent.process([
|
61 | "-V",
|
62 | "--resume", '601-multiJobSubmittedReport.xml',
|
63 | "--counter", 651,
|
64 | "--timeout", 10,
|
65 | "--retry", 30,
|
66 | "--follow"
|
67 | ]).then(function (batch2) {
|
68 |
|
69 | expect(batch2).toBeDefined();
|
70 | expect(batch2.finishedjobs).toBe(batch2.totaljobs);
|
71 | done();
|
72 | }, faildone);
|
73 | }
|
74 | agent.process([
|
75 | "-V",
|
76 | "--type", 'batch',
|
77 | "--stuff", 'spec/oefgc.tgz',
|
78 | "--exercise", exercise1.safecookie,
|
79 | "--offset", 10,
|
80 | "--timeout", 5,
|
81 | "--retry", 3,
|
82 | "--counter", 600,
|
83 | "--follow"
|
84 | ]).then(resumeBatch).catch(resumeBatch);
|
85 | }, 500*1000);
|
86 |
|
87 | it("resume the former (already completed) batch", function (done) {
|
88 | agent = CodeGradX.getCurrentAgent();
|
89 | var faildone = make_faildone(done);
|
90 | agent.process([
|
91 | "--resume", '601-multiJobSubmittedReport.xml',
|
92 | "--counter", 671,
|
93 | "--follow"
|
94 | ]).then(function (batch) {
|
95 | expect(batch).toBeDefined();
|
96 | expect(batch.finishedjobs).toBe(batch.totaljobs);
|
97 | expect(batch.jobs.third).toBeDefined();
|
98 | done();
|
99 | }, faildone);
|
100 | }, 500*1000);
|
101 |
|
102 | });
|