Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Proposal: Bring Back sauceProxy configuration #4405

Closed
kenisteward opened this issue Jul 25, 2017 · 5 comments · Fixed by #4419
Closed

Proposal: Bring Back sauceProxy configuration #4405

kenisteward opened this issue Jul 25, 2017 · 5 comments · Fixed by #4419
Assignees

Comments

@kenisteward
Copy link

Bug report

  • Node Version: 6.9.1
  • Protractor Version: 5.1.2
  • Angular Version: ^4.0.0
  • Browser(s): All
  • Operating System and Version Windows 7
  • Your protractor configuration file
const conf = require('./e2e/config/conf.e2e.json');
const { SpecReporter } = require('jasmine-spec-reporter');
const jasmineReporters = require('jasmine-reporters');

const prerun = { "background": true, "executable": "sauce-storage:auth_sauce.exe" };
const shartTestFiles = false;
const maxInstances = 1;

console.log("proxy is " + process.env.HTTP_PROXY + '--------------------------------------');

exports.config = {
  SELENIUM_PROMISE_MANAGER: 0,
  sauceBuild: process.env.JENKINS_BUILD_NUMBER || 'localTestBuildNumber__00',
  sauceUser: process.env.SAUCE_USERNAME || 'test',
  sauceKey: process.env.SAUCE_ACCESS_KEY || 'test',
  sauceSeleniumUseHttp: true,
  sauceSeleniumAddress: 'localhost:4445/wd/hub',
  webDriverProxy: process.env.HTTP_PROXY,
  multiCapabilities: [

    // {
    //   build,
    //   buildName,
    //   "name": "Windows 7 IE 11",
    //   "username": conf.sauceUser,
    //   "accessKey": conf.sauceKey,
    //   "tunnel-identifier": "shepherd-jenkins",
    //   "platform": "Windows 7",
    //   "browserName": "internet explorer",
    //   "version": "11",
    //   "avoid-proxy": true,
    //   "unexpectedAlertBehaviour": "ignore",
    //   maxInstances,
    //  shartTestFiles,
    //   prerun
    // },
    {
      count: 1,
      "name": "Windows 7 chrome 57",
      "tunnel-identifier": "shepherd-jenkins",
      "platform": "Windows 7",
      "browserName": "chrome",
      chromeOptions: {
        prefs: {
          'credentials_enable_service': false,
          'profile': {
            'password_manager_enabled': false
          }
        },
        args: [
          '--disable-cache',
          '--disable-application-cache',
          '--disable-offline-load-stale-cache',
          '--disk-cache-size=0',
          '--v8-cache-options=off'
        ]
      },
      "version": "57",
      shartTestFiles,
      prerun
    },
  ],
  allScriptsTimeout: 11000,
  seleniumArgs: ['--ignore_ssl'],
  specs: [
    './e2e/**/*.e2e-spec.ts',
  ],

  directConnect: true,
  baseUrl: 'my.url.com',
  framework: 'jasmine2',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function () {
    }
  },

  onPrepare() {
    let capabilities
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });

    jasmine.getEnv().addReporter(new SpecReporter({
      spec: { displayStacktrace: true }
    }));

    return browser.getProcessedConfig().then((c) => {
      capabilities = c.capabilities;
      // used to change the namespace for the data.
      process.env.CURRENT_BROWSER = c.capabilities.browserName.replace(new RegExp(' ', 'g'), '-');
      jasmine.getEnv().addReporter(
        new jasmineReporters.JUnitXmlReporter({
          filePrefix: c.capabilities.browserName,
          consolidateAll: true,
          modifySuiteName: function (generatedSuiteName, suite) {
            // this will produce distinct suite names for each capability,
            // e.g. 'firefox.login tests' and 'chrome.login tests'
            return c.capabilities.browserName + '.' + generatedSuiteName;
          }
        }));

      return browser.driver.get(c.baseUrl).then(function () {
        browser.sleep(2000);
      });
    });
  },

  onComplete() {
    return browser.getProcessedConfig().then(function (c) {
      return browser.getSession().then(function (session) {
        // required to be here so saucelabs picks up reports to put in jenkins
        console.log('SauceOnDemandSessionID=' + session.getId() + ' job-name=' + c.capabilities.name);
      });
    });
  }
};

  • A relevant example test
    Setup Saucelabs in a jenkins build using node version 6.2.1 (i had 6.9.1 on my local)

  • Output from running the test
    Basically what it boils down to is I need my proxy to make the SauceLabs call to update my tests however I'm running my tests in Jenkins. When I run my tests, I get this problem

03:10:21 <div id="content">
03:10:21 <p>The following error was encountered while trying to retrieve the URL: <a href="http://myusername@localhost:4445/wd/hub/session">http://myusername@localhost:4445/wd/hub/session</a></p>
03:10:21 
03:10:21 <blockquote id="error">
03:10:21 <p><b>Access Denied.</b></p>
03:10:21 </blockquote>

Now I'm not sure if it was because the Jenkins job was running on NODE 6.2.1 or not but I do know it was usingthe webdriver proxy for my connection to the Sauce Selenium Relay but oddly was not including the saucekey. Whenever i got access denied it always only showed myusername only. I'm able using seleniumAddress and setting username / accesskey in each of my capabilities without setting webdriverproxy to run the tests.

Feature Request

My request would be to allow SauceLabs plugin to be configurable separate from the main testing connection like it used to be. Right now there is no way for me to tell Protractor this beucase webDriverProxy is used for the driverProvider config + SauceLabs config.

  • Reasons for adopting new feature
  • Is this a breaking change? (How will this affect existing functionality)
    It would be a breaking revert to what it previously was but it wouldn't be that big. I'd be willing to looking into doing the PR when I have time. I just don't know why sauceProxy was taken out because they are 2 separate usages of the proxy. At the very least have some way that I could maybe slip in my own SauceLabs plugin as we do the sauceAgent.

As a part of a relavant thing it would be also nice if that sauce driverProvider covered console.log(session / job); as you see in my configuration so it would be a more complete integration with saucelabs. (specifically reporting for the jenkins plugin but it doesn't hurt anything anywhere else)

@cnishina
Copy link
Member

cnishina commented Aug 1, 2017

This is the commit that was made that removed it and to use webdriverProxy 604fdbf

Here is the original issue why we removed it. #3694

Important to note that webdriverProxy was a variable in the configuration file but I do not believe it was used. I believe we decided to use webdriverProxy over sauceProxy since it was more consistent with the variable names in the sauce node module. If you need to switch between environments, I would suggest using environment variables or something based off of the os node module.

@cnishina cnishina closed this as completed Aug 1, 2017
@kenisteward
Copy link
Author

kenisteward commented Aug 1, 2017 via email

@cnishina cnishina reopened this Aug 1, 2017
@cnishina
Copy link
Member

cnishina commented Aug 1, 2017

I am having issues with how that is previously phrased. So I'm trying to get onboard but I don't understand.

You launch your test against saucelabs and need to use the proxy. This is currently defined as webdriverProxy previously defined as sauceProxy. Is it because we are initializing sauce with a proxy in the sauce constructor and then when we get a new driver instance we are trying to proxy again? See sauce constructor and get new driver

If that is the case, then I will put a PR to revert this change. We currently do not have a proxy service to test some of these changes.

@cnishina cnishina self-assigned this Aug 1, 2017
@cnishina cnishina removed the PRs plz! label Aug 1, 2017
@kenisteward
Copy link
Author

kenisteward commented Aug 1, 2017 via email

@cnishina
Copy link
Member

cnishina commented Aug 1, 2017

I can do this right now...

cnishina added a commit to cnishina/protractor that referenced this issue Aug 1, 2017
Reverts the change to PR angular#3868. Protractor should connect to Sauce Labs
via the sauceProxy. This is different than the webDriverProxy. The
webDriverProxy is tied to the browser session where we define where the
traffic will go through.

closes angular#4405
cnishina added a commit to cnishina/protractor that referenced this issue Aug 3, 2017
Reverts the change to PR angular#3868. Protractor should connect to Sauce Labs
via the sauceProxy. This is different than the webDriverProxy. The
webDriverProxy is tied to the browser session where we define where the
traffic will go through.

closes angular#4405
cnishina added a commit to cnishina/protractor that referenced this issue Aug 3, 2017
Reverts the change to PR angular#3868. Protractor should connect to Sauce Labs
via the sauceProxy. This is different than the webDriverProxy. The
webDriverProxy is tied to the browser session where we define where the
traffic will go through.

closes angular#4405
cnishina added a commit that referenced this issue Aug 3, 2017
Reverts the change to PR #3868. Protractor should connect to Sauce Labs
via the sauceProxy. This is different than the webDriverProxy. The
webDriverProxy is tied to the browser session where we define where the
traffic will go through.

closes #4405
cnishina added a commit to cnishina/protractor that referenced this issue Aug 14, 2017
Reverts the change to PR angular#3868. Protractor should connect to Sauce Labs
via the sauceProxy. This is different than the webDriverProxy. The
webDriverProxy is tied to the browser session where we define where the
traffic will go through.

closes angular#4405
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants