Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Conversation

@iraghumitra
Copy link
Contributor

@iraghumitra iraghumitra commented Dec 3, 2017

Contributor Comments

This PR aims to improve the existing e2e tests of metro-alerts in the areas mentioned below. The PR doesn't add/remove any functionality to the existing alerts ui. However, there are few changes in HTML templates where I a needed a new selector for tests.

  • Delete the contents of table 'metron_update' in HBase
    • I have added a nodes script that deletes the 'metron_update' table before each run of e2e tests
  • Ensure that the tests run consistently on latest version of node
    • I have tested and added a check to node version 8.9. If the version is less than 8.9 there is a warning and tests run continues
  • Improving description of test specs
    • Added meaningful descriptions wherever applicable. Let me know if we need any more descriptions
  • Run the tests on a headless browser to improve reliability
    • Added the headless option to protractor.conf.js
  • Stop polling in the UI, it might cause tests to be flaky by refreshing at an unexpected time
    • Added POLLING_DEFAULT_STATE to environment variables that would controll if polling is enabled in UI by default

The tests are written using:
OS: macOS High Sierra 10.13.1
nodejs: v8.9.1.
Chrome: 62.0.3202.94

The tests should run reasonably well on other platforms since I personally didn't test on them I would request you to report any tests failure with information about your OS, nodejs and browser version.

I bumped up the version of the protractor to 5.2.0, so please run npm install before testing the PR. Please let me know if you need any more details about the PR.

Testing

If all the e2e tests run fine the PR is good.

Documentation

No new documentation is needed specifically for this PR. The steps to run the e2e tests remains the way they are before. I added a couple of caveats in Readme about deleting 'metron_update' table and headless chrome. Please let me know if we can improve our docs for e2e tests I would be glad to add it.

Pull Request Checklist

Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.

In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:

For all changes:

  • Is there a JIRA ticket associated with this PR? If not one needs to be created at Metron Jira.
  • Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
  • Has your PR been rebased against the latest commit within the target branch (typically master)?

For code changes:

  • Have you included steps to reproduce the behavior or problem that is being changed or addressed?

  • Have you included steps or a guide to how the change may be verified and tested manually?

  • Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:

    mvn -q clean integration-test install && build_utils/verify_licenses.sh 
    
  • Have you written or updated unit tests and or integration tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

  • Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via site-book/target/site/index.html:

    cd site-book
    mvn site
    

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.

@justinleet
Copy link
Contributor

I haven't looked at the code yet, but I was able to pull this down and run the e2e tests repeatedly without failures, so this is definitely great stuff.

export let DEFAULT_FACETS = ['source:type', 'ip_src_addr', 'ip_dst_addr', 'host', 'enrichments:geo:ip_dst_addr:country'];
export let DEFAULT_GROUPS = ['source:type', 'ip_src_addr', 'ip_dst_addr', 'host', 'enrichments:geo:ip_dst_addr:country'];
export let INDEXES = environment.indices ? environment.indices.split(',') : [];
export let POLLING_DEFAULT_STATE = environment.defaultPollingState;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the POLLING_DEFAULT_STATE setting do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added info for this in Readme and CC

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to change this to a better name? Something like DISABLE_POLLING? Setting POLLING_DEFAULT_STATE to true to stop polling doesn't make sense to me.

@merrimanr
Copy link
Contributor

Took a first pass at this and I feel like the e2e tests are much improved. Great progress and good job so far. I was able to get several successful runs whereas before it was difficult to get a single successful run.

A couple of comments/suggestions:

  • I noticed a warning message stating I wasn't on a recent enough version of nodejs. I think we should be using the maven frontend plugin to run tests so that we guarantee a consistent version is used. I submitted a PR as an example of how to do this.

  • I noticed there are still several browser.sleep statements throughout the tests (I counted 20). I think our goal should be to remove all of them. I know some of these should definitely be removed (alerts-list.po.ts, line 87) and may have just been missed. If there are cases where we MUST have them, I think those cases needed to be discussed and justified.

  • I feel like the "should expand all facets" and "should collapse all facets" tests in alert-filters.e2e-spec.ts are unnecessary (and would allow us to remove a couple browser.sleep statements). These tests are simply opening and closing bootstrap widgets which is controlled by code we don't maintain (bootstrap). I would instead prefer a test that selects a filter and checks that the search box and results are properly updated.

  • I have ran into these errors a couple times. Not sure if I just ended up in a bad state somehow or if it's because I'm running tests through Maven:

✗ should have all the steps for meta alerts workflow
- Failed: unknown error: Element <span _ngcontent-c14="" class="checkmark"></span> is not clickable at point (1278, 102). Other element would receive the click: <div _ngcontent-c14="" class="col-1 px-0">...</div>

✗ should create a meta alert from nesting of more than one level
- Failed: unknown error: Element <i _ngcontent-c7="" aria-hidden="true" class="fa fa-link" data-animation="false" data-placement="left" data-toggle="tooltip" style="color: #32ABDF;" title="Merge Alerts"></i> is not clickable at point (1350, 503). Other element would receive the click: <div _ngcontent-c14="" class="metron-slider-pane-details load-right-to-left dialog1x">...</div>

Removed sleep for clickActionDropdownOption
Removed the version check for node
@iraghumitra
Copy link
Contributor Author

iraghumitra commented Dec 6, 2017

@merrimanr

  • I removed the node version check in the ui code
  • The browser.sleep is used in following areas
    - When we are using methods like waitForText, few times I see the test fails saying that that it got the text we were waiting to change which doesn't make sense. So, in this case, i am just yielding the main thread with a sleep of 500 milliseconds.
    - Create/Add meta-alert, these calls takes few seconds at times.
    - When we use animation to slide in the details pane, we don't have a class that gets added/removed for this so it makes it difficult for us to know when the pane is loaded. We can add/remove a class for animation by moving the slider to a component or directive. This might be out of scope for current PR.
  • Refactored tests for Facets
  • I ran test multiple times I am not able to hit this issue, can you attach the stack trace it might give me additional info to debug. (by any chance did you remove the sleep in alerts-list.po.ts, line 87 for testing ?)

@iraghumitra
Copy link
Contributor Author

@merrimanr renamed the variable POLLING_DEFAULT_STATE to DISABLE_POLLING

@justinleet
Copy link
Contributor

I've hit the same intermittent errors trying this, e.g.

[INFO]       - Failed: unknown error: Element <button _ngcontent-c2="" aria-controls="time-range" aria-expanded="false" class="btn btn-secondary btn-search" data-animation="false" data-target="#time-range" data-toggle="collapse" type="button">...</button> is not clickable at point (1279, 95). Other element would receive the click: <th _ngcontent-c13="" style="width: 30%">...</th>

One of the very first things that failed was

[INFO]     ✗ should display error message for invalid credentials
[INFO]       - Failed: Error while waiting for Protractor to sync with the page: true

Is it possible there's an intermittent error getting the tests initially lined up that just carries through everything?

@iraghumitra Can you also update the README with the instructions for running this with the mvn profile + any troubleshooting or other steps that need to happen?

@mmiklavc
Copy link
Contributor

Something I'm missing?

./scripts/start-server-for-e2e.sh

/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/@angular/cli/bin/ng:7
const CliConfig = require('../models/config').CliConfig;
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:945:3

@mmiklavc
Copy link
Contributor

Seems that my NodeJS and npm versions got mangled since last time I ran this. Perhaps migrating laptops, upgrading to High Sierra, and switching from MacPorts to HomeBrew might have something to do with it ;)

@mmiklavc
Copy link
Contributor

A couple notes for the community - if your node/npm versions are out of date and you've already built the project, you'll run into trouble with versions not matching against the expected node version, e.g. Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 9.x. I deleted the node_modules directory entirely, rm -r metron-alerts/node_modules, re-ran the install, npm install, and then the start server script ran successfully. Just to note, the server script does not background the process, so you'll need to manually do that or use 2 windows to run the e2e tests.

@mmiklavc
Copy link
Contributor

Should we also run the tests using the new Maven profile? mvn test -Pe2e

The README should probably be updated to reflect this as well.

@mmiklavc
Copy link
Contributor

OK, I was able to get the tests to run. First run I get a single error. @merrimanr and I are talking through it now.

[INFO]   Test spec for login page
[INFO]     ✗ should display error message for invalid credentials
[INFO]       - Failed: Error while waiting for Protractor to sync with the page: true
[INFO] .    ✓ should login for valid credentials
[INFO] .    ✓ should logout
...
[INFO] Failures:
[INFO] 1) Test spec for login page should display error message for invalid credentials
[INFO]   Message:
[INFO]     Failed: Error while waiting for Protractor to sync with the page: true
[INFO]   Stack:
[INFO]     Error: Error while waiting for Protractor to sync with the page: true
[INFO]         at runWaitForAngularScript.then (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/built/browser.js:463:23)
[INFO]         at ManagedPromise.invokeCallback_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1376:14)
[INFO]         at TaskQueue.execute_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3084:14)
[INFO]         at TaskQueue.executeNext_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27)
[INFO]         at asyncRun (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2927:27)
[INFO]         at /Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7
[INFO]         at process._tickCallback (internal/process/next_tick.js:109:7)
[INFO]     From: Task: <anonymous>
[INFO]         at pollCondition (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2195:19)
[INFO]         at /Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2191:7
[INFO]         at new ManagedPromise (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1077:7)
[INFO]         at ControlFlow.promise (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2505:12)
[INFO]         at /Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2190:22
[INFO]         at TaskQueue.execute_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3084:14)
[INFO]         at TaskQueue.executeNext_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27)
[INFO]         at asyncRun (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2974:25)
[INFO]         at /Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7
[INFO]         at process._tickCallback (internal/process/next_tick.js:109:7)
[INFO]     From: Task: <anonymous wait>
[INFO]         at scheduleWait (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2188:20)
[INFO]         at ControlFlow.wait (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2517:12)
[INFO]         at Driver.wait (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:934:29)
[INFO]         at run (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/built/browser.js:59:33)
[INFO]         at ProtractorBrowser.to.(anonymous function) [as wait] (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/built/browser.js:67:16)
[INFO]         at Object.waitForElementVisibility (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/utils/e2e_util.ts:43:20)
[INFO]         at LoginPage.setUserNameAndPassword (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.po.ts:42:16)
[INFO]         at UserContext.<anonymous> (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.e2e-spec.ts:29:20)
[INFO]         at step (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.e2e-spec.ts:32:23)
[INFO]         at Object.next (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.e2e-spec.ts:13:53)
[INFO]     From: Task: Run it("should display error message for invalid credentials") in control flow
[INFO]         at UserContext.<anonymous> (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/jasminewd2/index.js:94:19)
[INFO]         at /Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/jasminewd2/index.js:64:48
[INFO]         at ControlFlow.emit (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/events.js:62:21)
[INFO]         at ControlFlow.shutdown_ (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2674:10)
[INFO]         at shutdownTask_.MicroTask (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2599:53)
[INFO]     From asynchronous test:
[INFO]     Error
[INFO]         at Suite.<anonymous> (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.e2e-spec.ts:27:5)
[INFO]         at Object.<anonymous> (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/e2e/login/login.e2e-spec.ts:20:1)
[INFO]         at Module._compile (module.js:571:32)
[INFO]         at Module.m._compile (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/ts-node/src/index.ts:406:23)
[INFO]         at Module._extensions..js (module.js:580:10)
[INFO]         at Object.require.extensions.(anonymous function) [as .ts] (/Users/mmiklavcic/devprojects/metron/metron-interface/metron-alerts/node_modules/ts-node/src/index.ts:409:12)
[INFO]
[INFO] 41 specs, 1 failure
[INFO] Finished in 269.33 seconds
[INFO]
[INFO] **************************************************
[INFO] *                    Failures                    *
[INFO] **************************************************
[INFO]
[INFO] 1) Test spec for login page should display error message for invalid credentials
[INFO]   - Failed: Error while waiting for Protractor to sync with the page: true
[INFO]
[INFO] Executed 41 of 41 specs (1 FAILED) in 4 mins 29 secs.
[INFO] [13:58:41] I/launcher - 0 instance(s) of WebDriver still running
[INFO] [13:58:41] I/launcher - chrome #01 failed 1 test(s)
[INFO] [13:58:41] I/launcher - overall: 1 failed spec(s)
[INFO] [13:58:41] E/launcher - Process exited with error code 1

@merrimanr
Copy link
Contributor

I was reviewing the protractor documentation here and I noticed this:

Don’t forget to turn off control_flow, you cannot use a mix of async/await and the control flow: async/await causes the control flow to become unreliable (see github issue). So if you async/await anywhere in a spec, you should use the SELENIUM_PROMISE_MANAGER: false

I don't see that setting in protractor.conf.js. Shouldn't it be included? Have all the tests been updated to use async/await instead of web driver flow control?

@mmiklavc
Copy link
Contributor

Follow up from @merrimanr and my work yesterday. We upped the versions of Node to 9.2.1. Per the doc, >8 is required to work with async/await. For good measure, I also set the NPM version to 5.6.0. We didn't touch Jasmine, but the Protractor docs also state that it should be > 2.7. Looks like we are currently using 2.5.2 per the package.json file. We may want to consider increasing that version as well.

We added SELENIUM_PROMISE_MANAGER: false to protractor.conf.js and immediately got failures due to Promise use in the Protractor tests and configuration. e.g. var defer = protractor.promise.defer();. So we removed references to promises in the conf file and were able to get past that first batch of errors. Now we were into problems with the tests. I started with the login.e2e-spec.ts spec file and removed : Promise<any>. Running the tests again, the login tests were able to succeed.

There are still a large number of failures due to disabling the promise manager, but still having code throughout the test suite that leverages the older style. It's unclear if this will resolve all stability issues, but I think this is moving in the right direction.

@justinleet
Copy link
Contributor

@merrimanr @mmiklavc @iraghumitra What are the next steps towards being able to have this stable? It sounds like there was some playing around with versions, and that there may be some more structural changes to the code style. How do you propose we move forward?

I'd really like to see this stuff made stable and I'm happy to help out with more testing or whatever else we need.

@merrimanr
Copy link
Contributor

@justinleet I believe @iraghumitra is still working on the SELENIUM_PROMISE_MANAGER change proposed above but I will defer to him.

@ottobackwards
Copy link
Contributor

What is the status of this pr? it is 29 day without comment, and conflicted, literally, and perhaps figuratively

@iraghumitra
Copy link
Contributor Author

Got busy with too many things happening around me, will yield this a conclusion next week.

@ottobackwards
Copy link
Contributor

Please close this

@nickwallen
Copy link
Contributor

I also requested that this be closed in this ticket; https://issues.apache.org/jira/browse/INFRA-17251

@gmcdonald gmcdonald closed this Nov 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants