UNPKG

3.77 kBJavaScriptView Raw
1// Jasmine test related to the vmauthor virtual machine. The vmauthor
2// virtual machine hosts a full constellation of CodeGradX servers.
3// The vmauthor virtual machine is available from
4// http://paracamplus.com/CodeGradX/VM/latest/
5
6var CodeGradX = require('codegradxagent');
7var Agent = require('../codegradxvmauthor.js');
8var vmauthData = require('./vmauth-data.json');
9
10describe("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 //agent.state.debug(reason).show();
21 //console.log(reason);
22 fail(reason);
23 done();
24 };
25 }
26
27 // Get the safecookie identifying exercise com.paracamplus.li205.function.1
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 //console.log(exercise);
47 done();
48 }, faildone);
49 }, faildone);
50 }, faildone);
51 }, 10*1000); // 10 seconds
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 // Check that the batch is not yet completed:
59 // expect(batch.finishedjobs).toBeLessThan(batch.totaljobs);
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 // normally 6[05]1-multiJobSubmittedReport.xml are equal
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); // 500 seconds
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); // 500 seconds
101
102});