Skip to content

Commit

Permalink
fix up
Browse files Browse the repository at this point in the history
Signed-off-by: SamYuan1990 <yy19902439@126.com>
  • Loading branch information
SamYuan1990 committed Nov 2, 2020
1 parent 341ada4 commit 05cbdf3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions lib/libs.js
Expand Up @@ -185,14 +185,13 @@ exports.teardown = function teardown(CmdInfo,TurnInfo){
}

exports.tapeTPS = function tapeTPS(CmdInfo,TurnInfo){
var command = PrepareTape(CmdInfo,TurnInfo);
var command = this.PrepareTape(CmdInfo,TurnInfo);
// so far for testing
if (command.command=='echo'){
if (command.DryRun){
console.log(command);
return 0
}
rs = process.spawnSync(command.command,[
command.args
]);
rs = process.spawnSync(command.command,command.args);
if (rs.status !=0) {
return handleStatus(rs);
}
Expand All @@ -201,8 +200,8 @@ exports.tapeTPS = function tapeTPS(CmdInfo,TurnInfo){

exports.PrepareTape = function PrepareTape(CmdInfo,TurnInfo){
var command = {};
if (CmdInfo.TapeCLI=='echo'){
return command.command = 'echo'
if (CmdInfo.DryRun){
command.DryRun = true
}
command.command = 'docker';
command.args = ['run',
Expand Down
4 changes: 2 additions & 2 deletions routes/api.js
Expand Up @@ -41,8 +41,8 @@ router.get('/run', function(req, res, next) {
ShutDownCLI: req.query.ShutDownCLI,
tapeCount: parseFloat(req.query.TapeCount),
}
if (req.query.TapeCLI) {
CmdInfo.TapeCLI = req.query.TapeCLI;
if (req.query.DryRun) {
CmdInfo.DryRun = req.query.DryRun;
}
BatchTimeout = [];
BatchTimeoutArray = req.query.BatchTimeout.toString().split(",");
Expand Down
2 changes: 1 addition & 1 deletion test/app.test.js
Expand Up @@ -14,7 +14,7 @@ describe('# test app.js', function () {
});
it('GET /api/run', function (done) {
request
.get(`/api/run?BatchTimeout=1&MaxMessageCount=1&AbsoluteMaxBytes=1&PreferredMaxBytes=1&CoolDown=1&PrepareCLI=echo&StartCLI=echo&TapeCLI=echo&TapeCount=5000&ShutDownCLI=echo`)
.get(`/api/run?BatchTimeout=1&MaxMessageCount=1&AbsoluteMaxBytes=1&PreferredMaxBytes=1&CoolDown=1&PrepareCLI=echo&StartCLI=echo&DryRun=true&TapeCount=5000&ShutDownCLI=echo`)
.expect(200, done)
});
it('GET /api/getBatchTimeout', function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/lib.test.js
Expand Up @@ -8,7 +8,7 @@ describe('# libs', function () {
CoolDown: 1,
PrepareCLI: 'echo',
StartCLI: 'echo',
TapeCLI: 'echo',
DryRun: true,
ShutDownCLI: 'echo',
}
BatchTimeout = [2];
Expand Down

0 comments on commit 05cbdf3

Please sign in to comment.