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

E2e mock server #4456

Merged
merged 13 commits into from
Dec 11, 2019
Merged

E2e mock server #4456

merged 13 commits into from
Dec 11, 2019

Conversation

sumit116
Copy link
Contributor

@sumit116 sumit116 commented Nov 12, 2019

Type of change

  • Build related changes
  • CI related changes

Description of change

Our circle CI builds are failing frequently, and one of the obvious reasons for this, is inconsistency in the response from the bid server(s) that we have used for our e2e-tests. In most tests, we have used appnexus server which mostly is not returning any response in the expected time resulting in timeout errors that we see in our daily workflow, here is one example.

Hence we came up with this solution of using a mock server which would return response from a static file based on the request it receives. For this, we would add request and response pair files (one is added in this PR), and the mock-server with the help of its middleware (prebid-request.js) will search for the matching request and send the corresponding response. This would not only make our testing environment more stable but would also make the tests run faster.

@bretg
Copy link
Collaborator

bretg commented Nov 22, 2019

You just said the magic words: "testing environment more stable". I'm behind this now.

@robertrmartinez
Copy link
Collaborator

robertrmartinez commented Nov 22, 2019 via email

Copy link
Collaborator

@jaiminpanchal27 jaiminpanchal27 left a comment

Choose a reason for hiding this comment

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

I tried e2e test command but it didn't work. I tried running the banner test with changes made to wdio.conf file.

gulpfile.js Outdated
@@ -32,6 +32,9 @@ var prebid = require('./package.json');
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + ' */\n';
var port = 9999;
const prebidLocation = './src/prebid.js';
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the use for this const ?

gulpfile.js Outdated
@@ -309,6 +312,12 @@ function setupE2e(done) {
done();
}

gulp.task('updatepath', function(){
return gulp.src(['build/dev/*.js'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

test pages defined in e2e are using dist path. On running e2e-test, it will still hit the ut/v3 endpoint

}
res.type('json');
if (req.method === 'GET') {
response = 'apntag.handleCb(' + JSON.stringify(response) + ');';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not needed for Prebid

@lgtm-com
Copy link

lgtm-com bot commented Nov 26, 2019

This pull request introduces 1 alert when merging 4e6c2cb into 373f593 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@robertrmartinez
Copy link
Collaborator

I too am having issues running it locally.

I think we should add instructions on how to run it locally and all the things which are required.

@sumit116
Copy link
Contributor Author

sumit116 commented Nov 26, 2019

Hi @robertrmartinez , after switching to the branch you need to do:

  1. npm install
  2. gulp e2e-test --host=test.localhost

And it should run the banner test on all browsers. You can test the response from mock-server through network logs on browserstack or using live.browserstack hitting http://test.localhost:9999/test/pages/banner.html.

Please ignore any errors while npm install (may be you get related to jest) . If the mock-server process is not getting killed when the tests are completed, you would need to kill it manually. I am working on these two things but they should not restrict you running the tests. Please let me know if you still face any issues.

# Conflicts:
#	package-lock.json
@jaiminpanchal27 jaiminpanchal27 merged commit 4de8eb7 into master Dec 11, 2019
@sumit116 sumit116 mentioned this pull request Dec 27, 2019
9 tasks
@Fawke Fawke mentioned this pull request Apr 9, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants