Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ is to run ReadyAPI projects (functional API tests for primarily REST and SOAP se
The TestEngine-CLI is a command line interface for the API of the product. The tool can handle most administration of the
server as well as submitting test jobs and requesting reports.

## Install
Install testengine cli globally:

`npm install -g testengine-cli`
## Usage
All communication with the ReadyAPI TestEngine requires three settings.
* URL to TestEngine
Expand Down Expand Up @@ -112,6 +116,11 @@ Each job has a job ID, with the command "jobs cancel" a running (or queued) job

`testengine jobs cancel <job ID>`

### Delete a job
Each job has a job ID, with the command "jobs delete" a job can be deleted. A running/queued job must be canceled first to delete.

`testengine jobs delete <job ID>`

### Get the status of a job, using job ID without generating a report
Each job has a job ID, with the command "jobs cancel" a running (or queued) job can be canceled.

Expand Down
38 changes: 38 additions & 0 deletions bin/jobs_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module.exports = {
}
break;
}
case 'delete': {
if (args.length < 2) {
printModuleHelp();
} else {
deleteTestJob(args[1]);
}
break;
}
case 'status': {
if (args.length < 2) {
printModuleHelp();
Expand Down Expand Up @@ -114,6 +122,36 @@ function terminateTestJob(testjobId) {
})
}

function deleteTestJob(testjobId) {
let url = config.server + '/api/v1/testjobs'+ '/' + testjobId + '/delete';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slash can be part of the first string and doesnt need to be concateneted seperately.

'/api/v1/testjobs'+ '/' + testjobId + '/delete';
->
'/api/v1/testjobs/' + testjobId + '/delete'

util.output('Deleting job: '+testjobId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting, add space around operators

request.delete(url)
.auth(config.username, config.password)
.accept('application/junit+xml')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accept looks weird to me, I think it could be application/json, since json is what we return when there is an error. On success we don't return any data. Same goes for cancel(which I know you havent changed but I think it can be fixed too).

.send()
.end((err, result) => {
if (err !== null) {
if (('status' in err) && ('message' in result.body)) {
switch (err['status']) {
case 403:
util.error(err['status'] + ': ' + result.body['message']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is does the same as the default-case. So it can be removed. Maybe we dont need the switch at all?

break;
case 404:
util.output(`${err['status']}: Testjob not found`);
break;
default:
util.error(err['status'] + ': ' + result.body['message']);
return;
}
} else {
util.error(err);
}
} else {
util.output('Successfully deleted job');
}
})
}

function printReport (testjobId) {
const endPoint = config.server + '/api/v1/testjobs';
const url = endPoint + '/' + testjobId + '/report';
Expand Down