UNPKG

2.71 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 ]).then(function (user) {
38 expect(user).toBeDefined();
39 user.getCampaign('example').then(function (campaign) {
40 expect(campaign).toBeDefined();
41 expect(campaign.name).toBe('example');
42 campaign.getExercise(exerciseName).then(function (exercise) {
43 expect(exercise).toBeDefined();
44 exercise1 = exercise;
45 //console.log(exercise);
46 done();
47 }, faildone);
48 }, faildone);
49 }, faildone);
50 }, 10*1000); // 10 seconds
51
52 it("send a batch and get all jobs reports", function (done) {
53 agent = new CodeGradX.VMauthorAgent();
54 var faildone = make_faildone(done);
55 agent.process([
56 "-V",
57 "--user", vmauthData.login,
58 "--password", vmauthData.password,
59 "--type", 'batch',
60 "--stuff", 'spec/oefgc.tgz',
61 "--exercise", exercise1.safecookie,
62 "--offset", 30,
63 "--timeout", 10,
64 "--counter", 400,
65 "--follow"
66 ]).then(function (batch) {
67 expect(batch).toBeDefined();
68 expect(batch.finishedjobs).toBe(batch.totaljobs);
69 console.log(batch); // DEBUG
70 expect(batch.jobs.third).toBeDefined();
71 done();
72 }, faildone);
73 }, 500*1000); // 500 seconds
74
75});