Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
jio
Commits
11fe07cb
Commit
11fe07cb
authored
Aug 22, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
job management jio tests added
parent
077db937
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
27 deletions
+109
-27
test/jio/tests.js
test/jio/tests.js
+109
-27
No files found.
test/jio/tests.js
View file @
11fe07cb
...
@@ -651,44 +651,126 @@
...
@@ -651,44 +651,126 @@
});
});
/**
/**
* Tests job
workspace
* Tests job
management
*/
*/
test
(
"
Job
Workspace
"
,
function
()
{
test
(
"
Job
Management
"
,
function
()
{
var
workspace
=
{},
clock
,
jio
;
var
workspace
=
{},
clock
,
jio
,
o
=
{}
;
expect
(
2
);
expect
(
8
);
clock
=
sinon
.
useFakeTimers
();
clock
=
sinon
.
useFakeTimers
();
jio
=
new
JIO
({
jio
=
new
JIO
({
"
type
"
:
"
fake
"
,
"
type
"
:
"
fake
"
,
"
id
"
:
"
1 Job
Worksp
"
"
id
"
:
"
1 Job
Manage
"
},
{
},
{
"
workspace
"
:
workspace
"
workspace
"
:
workspace
});
});
jio
.
get
({
"
_id
"
:
"
a
"
},
{
"
max_retry
"
:
2
,
"
timeout
"
:
12
});
// Launch a get command, check the workspace and then respond
jio
.
get
({
"
_id
"
:
"
a
"
},
{
"
max_retry
"
:
2
,
"
timeout
"
:
12
}).
always
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
_id
"
:
"
a
"
,
"
b
"
:
"
c
"
,
"
ok
"
:
true
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Job respond
"
);
});
o
.
job1
=
{
"
kwargs
"
:
{
"
_id
"
:
"
a
"
},
"
options
"
:
{
"
max_retry
"
:
2
,
"
timeout
"
:
12
},
"
storage_spec
"
:
{
"
type
"
:
"
fake
"
,
"
id
"
:
"
1 Job Manage
"
},
"
method
"
:
"
get
"
,
"
created
"
:
new
Date
(
0
),
"
tried
"
:
1
,
"
state
"
:
"
running
"
,
"
modified
"
:
new
Date
(
0
),
"
max_retry
"
:
2
,
"
timeout
"
:
12
,
"
id
"
:
1
};
deepEqual
(
workspace
,
{
"
jio/jobs/{
\"
id
\"
:
\"
1 Job Manage
\"
,
\"
type
\"
:
\"
fake
\"
}
"
:
jIO
.
util
.
uniqueJSONStringify
([
o
.
job1
])
},
'
Job added, workspace have one job
'
);
clock
.
tick
(
1
);
fakestorage
[
"
1 Job Manage/get
"
].
success
({
"
_id
"
:
"
a
"
,
"
b
"
:
"
c
"
});
clock
.
tick
(
1
);
deepEqual
(
workspace
,
{},
'
Job ended, empty workspace
'
);
// Launch a get command which launches another get command
// check workspace after every command and respond
jio
.
get
({
"
_id
"
:
"
b
"
},
{
"
max_retry
"
:
2
,
"
timeout
"
:
12
}).
always
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
_id
"
:
"
b
"
,
"
c
"
:
"
d
"
,
"
ok
"
:
true
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
First job respond
"
);
});
clock
.
tick
(
1
);
fakestorage
[
"
1 Job Manage/get
"
].
storage
({
"
type
"
:
"
fake
"
,
"
id
"
:
"
2 Job Manage
"
}).
get
({
"
_id
"
:
"
c
"
}).
always
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
_id
"
:
"
c
"
,
"
d
"
:
"
e
"
,
"
ok
"
:
true
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Second job respond
"
);
});
o
.
job1
.
kwargs
.
_id
=
'
b
'
;
o
.
job2
=
{
"
kwargs
"
:
{
"
_id
"
:
"
c
"
},
"
options
"
:
{},
"
storage_spec
"
:
{
"
type
"
:
"
fake
"
,
"
id
"
:
"
2 Job Manage
"
},
"
method
"
:
"
get
"
,
"
created
"
:
new
Date
(
0
),
"
tried
"
:
1
,
"
state
"
:
"
running
"
,
"
modified
"
:
new
Date
(
0
),
"
max_retry
"
:
3
,
"
timeout
"
:
10000
,
"
id
"
:
2
};
deepEqual
(
workspace
,
{
"
jio/jobs/{
\"
id
\"
:
\"
1 Job Manage
\"
,
\"
type
\"
:
\"
fake
\"
}
"
:
jIO
.
util
.
uniqueJSONStringify
([
o
.
job1
,
o
.
job2
])
},
'
Job calls another job, workspace have two jobs
'
);
clock
.
tick
(
1
);
fakestorage
[
'
1 Job Manage/get
'
].
end
();
deepEqual
(
workspace
,
{
deepEqual
(
workspace
,
{
"
jio/jobs/{
\"
id
\"
:
\"
1 Job Worksp
\"
,
\"
type
\"
:
\"
fake
\"
}
"
:
jIO
.
util
.
"
jio/jobs/{
\"
id
\"
:
\"
1 Job Manage
\"
,
\"
type
\"
:
\"
fake
\"
}
"
:
jIO
.
util
.
uniqueJSONStringify
([{
uniqueJSONStringify
([
o
.
job2
])
"
kwargs
"
:
{
"
_id
"
:
"
a
"
},
},
'
First Job ended, second still there
'
);
"
options
"
:
{
"
max_retry
"
:
2
,
"
timeout
"
:
12
},
"
storage_spec
"
:
{
"
type
"
:
"
fake
"
,
"
id
"
:
"
1 Job Worksp
"
},
fakestorage
[
'
1 Job Manage/get
'
].
success
({
"
_id
"
:
"
b
"
,
"
c
"
:
"
d
"
});
"
method
"
:
"
get
"
,
clock
.
tick
(
1
);
"
created
"
:
new
Date
(
0
),
"
tried
"
:
1
,
fakestorage
[
'
2 Job Manage/get
'
].
success
({
"
_id
"
:
"
c
"
,
"
d
"
:
"
e
"
});
"
state
"
:
"
running
"
,
clock
.
tick
(
1
);
"
modified
"
:
new
Date
(
0
),
"
max_retry
"
:
2
,
deepEqual
(
workspace
,
{},
'
No more job in the queue
'
);
"
timeout
"
:
12
,
});
"
id
"
:
1
}])
/**
},
'
Check workspace
'
);
* Test job recovery
*/
clock
.
tick
(
1
);
test
(
'
Job Recovery
'
,
function
()
{
fakestorage
[
"
1 Job Worksp/get
"
].
success
({
"
_id
"
:
"
a
"
,
"
b
"
:
"
c
"
});
expect
(
0
);
clock
.
tick
(
1
);
// create instance
// create a job
deepEqual
(
workspace
,
{},
'
Check workspace
'
);
// copy workspace
// create instance with copied workspace
// wait for action
});
});
}));
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment