Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not possible to update Sauce Labs job status when sauce connect is already running #18

Closed
bartoszkaczorek opened this issue Jan 27, 2015 · 4 comments

Comments

@bartoszkaczorek
Copy link

bartoszkaczorek commented Jan 27, 2015

I'm running intern functional tests on Sauce Labs and in our environment the sauce connect is always up and running. I'm able to run tests using NullTunnel.js and specifying "tunnelOptions.clientUrl" (pointing to our sauce connect), but this way the Sauce Labs job status is not being updated. I'm not able to use SauceLabsTunnel.js in this case, because it will complain about sauce connect already running. Is it possible to configure SauceLabsTunnel.js in the way that it will allow for the sauce connect to be already running, and then it would update the Sauce Labs job status? Currently I have written a mixed version of those tunnels and called it "NullSauceTunnel.js" which works for me, but it would be better to have an option to configure it natively.

Below is the code of my "NullSauceTunnel.js":

/**
* @module digdug/NullSauceTunnel
*/

var Promise = require('dojo/Promise');
var Tunnel = require('./Tunnel');
var util = require('./util');
var urlUtil = require('url');
var request = require('request');

function success() {
return Promise.resolve();
}

/**
* A no-op tunnel.
*
* @constructor module:digdug/NullSauceTunnel
* @extends module:digdug/Tunnel
*/
function NullSauceTunnel() {
Tunnel.apply(this, arguments);
}

var _super = Tunnel.prototype;
NullSauceTunnel.prototype = util.mixin(Object.create(_super), /** @lends module:digdug/NullTunnel */ {
auth: '',
isDownloaded: true,
download: success,
start: function () {
this.isRunning = true;
return success();
},
stop: function () {
this.isRunning = false;
return success();
},
sendJobState: function (jobId, data) {

var url = urlUtil.parse(this.restUrl || 'https://saucelabs.com/rest/v1/');
url.auth = this.username + ':' + this.accessKey;
url.pathname += this.username + '/jobs/' + jobId;

payload = JSON.stringify({
build: data.buildId,
'custom-data': data.extra,
name: data.name,
passed: data.success,
public: data.visibility,
tags: data.tags
});

var result = new Promise.Deferred();

request({
body: payload,
headers: {
"accept":"application/json"
},
auth : {
"username" : this.username,
"password" : this.accessKey
},
method : "PUT",
proxy: this.proxy,
url : urlUtil.format(url)

}, function (error, response, body) {
response.data = body;
result.resolve(response);
});

return result.promise.then(function (response) {
if (response.data) {
var data = JSON.parse(response.data);

if (data.error) {
throw new Error(data.error);
}

if (response.statusCode !== 200) {
throw new Error('Server reported ' + response.statusCode + ' with: ' + response.data);
}
}
else {
throw new Error('Server reported ' + response.statusCode + ' with no other data.');
}
});
}
});

module.exports = NullSauceTunnel;
@csnover
Copy link
Member

csnover commented Apr 1, 2015

Note that your NullSauceTunnel could be way simpler if you just extend NullTunnel and copy over the sendJobState function from SauceLabsTunnel:

var NullTunnel = require('digdug/NullTunnel');
var SauceLabsTunnel = require('digdug/SauceLabsTunnel');

function NullSauceTunnel() {
  NullTunnel.apply(this, arguments);
}
NullSauceTunnel.prototype = Object.create(NullTunnel.prototype);
NullSauceTunnel.prototype.constructor = NullSauceTunnel;
NullSauceTunnel.prototype.sendJobState = SauceLabsTunnel.prototype.sendJobState;
module.exports = NullSauceTunnel;

@csnover
Copy link
Member

csnover commented Apr 1, 2015

We don’t have any plans to separate the service reporting part from the tunnel any time in the foreseeable future, but if this is important to you please do send a patch and it can be added.

@bartoszkaczorek
Copy link
Author

Actually my code in NullSauceTunnel cannot be currently simplified due to proxy issues. (I'm using different request library)

@jason0x43
Copy link
Member

Closing this due to inactivity, and because the core issue (that there were proxy issues with the SauceLabsTunnel) is really what should be addressed. We can re-open this in the Intern tracker if it's still a desirable feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants