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