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

Run service tests on a given (remote) instance; test on [jetbrains] #2195

Merged
merged 9 commits into from
Nov 25, 2018
Merged

Run service tests on a given (remote) instance; test on [jetbrains] #2195

merged 9 commits into from
Nov 25, 2018

Conversation

platan
Copy link
Member

@platan platan commented Oct 19, 2018

This PR gives an option (--url) to run service tests on a given instance. It can be used to check if given instance is working correctly, e.g. after deployment.
Moreover I had to add an option (--skip-intercepted) to skip tests which intercepts requests (by intercept or by networkOff).
An example command:

 npm run test:services -- --only=jetbrains --url=https://shields-metrics1.now.sh --skip-intercepted

Is it useful? What do you think about it?

@platan platan changed the title Run service tests on a given (remote) instance Run service tests on a given (remote) instance; test on [jetbrains] Oct 19, 2018
@platan platan closed this Oct 19, 2018
@shields-ci
Copy link

shields-ci commented Oct 19, 2018

Warnings
⚠️ This PR modified helper functions in `lib/` but not accompanying tests.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @platan!

Generated by 🚫 dangerJS

@platan platan reopened this Oct 19, 2018
Copy link
Member

@PyvesB PyvesB left a comment

Choose a reason for hiding this comment

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

To be honest, it seems quite unnatural to me to run development-oriented test suites on remote/live instances. Once something is deployed and configured, in my opinion we should avoid tampering with it by running processes that do not pertain to its normal flow of execution. To check that an instance is working correctly after a deployment, wouldn't treating it as a black box by hitting it with a few badge requests be sufficient to assert that it is working properly?

Furthermore, our test suite is quite bulky and some services in particular have really slow tests. Others consume quite a few API calls from our rate limits, which is not great.

Those are my quick thoughts on the matter, I'll hand over to other maintainers for their opinions. 😉

@paulmelnikow
Copy link
Member

I think this makes sense. It's one of the use cases I had in mind when I worked on #927. It could be a nicer way to run our nightly tests on staging.

To check that an instance is working correctly after a deployment, wouldn't treating it as a black box by hitting it with a few badge requests be sufficient to assert that it is working properly?

Hehe, maybe not, though it's a good start, and it's basically what we do now. 🙃I might not wait for the entire suite to run, but hitting a few of the service tests in a reliable and automated way would make a nice post-deploy smoke tests.

Running the full suite exercises a lot of code and provides a lot of confidence things are working.

// is followed by a colon
protocol: 'http:',
hostname: 'localhost',
port: 1111,
Copy link
Member

Choose a reason for hiding this comment

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

I see that this is trying to make things more DRY, though I wonder if it would be clearer to put the URL here, and also more consistent with the other URLs we configure. I also think this could be loaded from the environment, as it's a pretty unusual case.

Something like:

liveServerUrl: process.env.LIVE_SERVER_URL

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Done.

const specs = this.specs

const fn = this._only ? describe.only : describe
// eslint-disable-next-line mocha/prefer-arrow-callback
fn(this.title, function() {
specs.forEach(spec => {
spec.toss()
if (!options.skipIntercepted || !spec.intercepted) {
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit difficult to follow how skipIntercepted is getting passed around here. I'm not sure I have a better solution, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I used an environment variable to set this option via test-config and code looks better now in opinion. It's a separate commit and revert it if required 0974be4

@@ -16,6 +20,9 @@ class Runner {
* Prepare the runner by loading up all the ServiceTester objects.
*/
prepare() {
if (this.options.testedServerUrl) {
testConfig.tested = this.options.testedServerUrl
Copy link
Member

Choose a reason for hiding this comment

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

It would be better not to mutate the test config; perhaps better to set it from the environment inside test-config, as I mention below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you, done :-)

@chris48s chris48s added the operations Hosting, monitoring, and reliability for the production badge servers label Oct 28, 2018
@paulmelnikow
Copy link
Member

Hey @platan, are you up for picking this up?

@platan
Copy link
Member Author

platan commented Nov 15, 2018

@paulmelnikow I will be able to look at this next week.

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2195 November 19, 2018 21:16 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2195 November 24, 2018 13:30 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2195 November 24, 2018 13:39 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2195 November 24, 2018 13:48 Inactive
@platan
Copy link
Member Author

platan commented Nov 24, 2018

@paulmelnikow Thank you for the review. I've changed the code, diff is smaller and it should look better now.

module.exports = {
port: 1111,
get testedServerUrl() {
Copy link
Member

Choose a reason for hiding this comment

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

The getter is a nice way to handle runtime overriding!

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2195 November 24, 2018 20:01 Inactive
@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
operations Hosting, monitoring, and reliability for the production badge servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants