Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

METRON-2023 [UI] Covering Grok Parser Creation with Cypress tests #1350

Closed
wants to merge 2 commits into from

Conversation

tiborm
Copy link
Contributor

@tiborm tiborm commented Mar 5, 2019

Contributor Comments

In this PR I introducing Cypress in Config UI and adding a Cypress test to the Config UI to cover Grok Parser Creation. To do this I made a simplified common test setup across Config and Alert UI to bring them to the same platform.
I also had to remove maven-frontend-plugin to fix issues we faced with on Travis while we tried to add cypress to Config UI project.

The list of changes are the following:

  • adding Grok Parser creation test
  • removing additional test server solution from Alert UI
  • using standard ng serve command to fire up both Alert and Config UI's for testing
  • removing maven-frontend-plugin, excluding UI from maven install and test loops and letting tests run on Travis's own node.js (the issue was deeply investigated and this is the only way to fix issues in the cypress install phase)
  • introducing shell script to execute UI tests

Steps to validate

Please check build logs in Travis CI to see the output of the UI tests.
https://travis-ci.org/apache/metron/jobs/502040547

Under this link you can find a build failing where I intentionally broke a test to see whether it breaks the build too.

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 && dev-utilities/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.

@@ -23,7 +23,7 @@ env:
- SCRIPT="mvn surefire:test@unit-tests -T 2C"
- SCRIPT="mvn surefire:test@integration-tests"
- SCRIPT="mvn clean site --projects site-book"
- SCRIPT="mvn test --projects metron-interface/metron-config,metron-interface/metron-alerts"
- SCRIPT="./metron-interface/scripts/run-all-ui-test.sh"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Migrated to bash script from maven. manven-frontend-plugin thrown error when tried to unzip Cypress.

@@ -53,8 +51,5 @@ before_cache:
cache:
timeout: 1000
directories:
- $HOME/.npm-cache
- $HOME/.npm-prefix
- metron-interface/metron-config/node_modules
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Migrated to Travis CI's own node/npm instance managed by nvm. The above configs no longer needed.

@@ -1 +1 @@
v9.11.1
v10.15.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With .nvmrc we can pin down the node/npm version both on Travis and local.
Upgraded to the latest LTS node version.

"cypress:open": "cypress open",
"cypress:ci": "ng build --prod && run-p --race start:ci cypress:run",
"start:ci": "node ./scripts/alerts-server.js -c alerts_ui_cypress.yml"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Npm scripts have been unified in the two UI project.

"tslint": "~5.0.0",
"typescript": "~2.9.2",
"yamljs": "^0.3.0"
"typescript": "~2.9.2"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the simplification of the way we fire up UIs for testing in Travis, we're able to eliminate 5 of our dependencies with adding only one.

</executions>
</plugin>
</plugins>
</build>
</project>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the pom.xml to have our two UI's in the maven project tree (makes it easier to import etc.), but I removed the two UI from the install and test goals.
Also tried to upgrade to the latest maven-frontend-plugin 1.7.5 but it hasn't fixed the unzipping issue.

echo "| Checking Apache license headers... |"
echo "└─────────────────────────────────────┘"
./scripts/prepend_license_header.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, git recognized this change as a rename. It is actually a removal of a yml config file (belongs to our previous test server setup, no longer needed) and the addition of a shell scirpt.

"rawMessageStrategy": "DEFAULT",
"rawMessageStrategyConfig": {}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Response mock for GROK parser creation test.

"Ise": "org.apache.metron.parsers.ise.BasicIseParser",
"GrokWebSphere": "org.apache.metron.parsers.websphere.GrokWebSphereParser",
"Bro": "org.apache.metron.parsers.bro.BasicBroParser"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Response mock for GROK parser creation test.

SCRIPTS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$SCRIPTS_ROOT/../node_modules/@angular/cli/bin/ng serve --proxy-config proxy.conf.json --aot $@
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, git recognized this change as a rename. It is actually a removal of a yml config file (belongs to our previous test server setup, no longer needed) and the addition of a shell script we used to fire up the UI locally.

echo " _/_/ "
echo ""

./metron-config/scripts/run-all-test.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is hard to distinguish the output of the two UI, therefore, I added the echos above.

<!-- Checkstyle is LGPL. We derive ours from their base, but don't ship it, so it's fine use.
Since it is derived, we shouldn't get an Apache header -->
<exclude>checkstyle.xml</exclude>
<!-- Alerts UI e2e test data -->
<exclude>e2e/mock-data/alerts_ui_e2e_index.data</exclude>
<exclude>**/e2e/mock-data/alerts_ui_e2e_index.data</exclude>
<!-- retry files generated by Ansible during a failure -->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without wildcards, the rat check failed to me on my local machine. With this change, it works both local and on Travis.

@sardell
Copy link
Contributor

sardell commented Mar 5, 2019

I also had to remove maven-frontend-plugin to fix issues we faced with on Travis while we tried to run UI test by mvn.

@tiborm Could you give a brief explanation of your research and testing that led to this change?

@tiborm
Copy link
Contributor Author

tiborm commented Mar 5, 2019

@sardell Our build jobs started to fail at some point. The cause of the failure was that mvn install was unable to execute unzipping in Cypress post install script without a mysterious error. Few other guys experienced similar issues.
I found no other way to fix failing mvn install step other than removing maven-frontend-plugin and migrating to bash scripts. I intentionally left a branch which contains all changes (tests, simplified test server, npm script normalization, removal of extra dependencies, node/npm version bump etc.) and still failing. Because nvm install step failing all other build job fails too most of the time.
U can check it here: https://travis-ci.org/tiborm/metron/builds/500373545
I found no reason for using maven-frontend-plugin.

  • It creates a very uncommon execution environment to our build and our tests (node, npm installed by it an also all the following npm scripts). I doubt that any npm module developer tests their install/build process against having this plugin around it.
  • It adds extra complexity to the UI projects compared to node version manager supported by Travis natively (even in a language: java setup).
  • I also experienced that it slows down the test execution on my local machine.

I found cypress reacted on the issue at the time I writeing this. But not yet proven fix out there.

@tiborm
Copy link
Contributor Author

tiborm commented Mar 5, 2019

Please also consider that the Trevis issue was experienced first when added cypress to Config UI (as part of the migration from protractor). Having it only in a single project (Alert UI in this case) show no issues.
Please also note that the problem is not with Cypress it self. It caused by the extracition/unzipping of the Cypress binary made by a module called yauzl. And only if cypress added to multiple projects. This is why I beleive that the issue is somehow related to the dependency cahcing in the mvn install process or the execution context of our cypress install in some way.
The version of the Cypress in Config UI in this branch is exactly the same we have in Alert UI in the master. Comparision included the version of all the dependecies too.

@sardell
Copy link
Contributor

sardell commented Mar 6, 2019

@tiborm Thanks for the explanation. Besides needing this change to resolve the unzipping issue, I also agree that we are adding a layer of complexity by running our front-end tests using maven. I don't see any obvious benefit to doing things this way, and it makes our use case unnecessarily unique. It also makes sense to include this change with this PR since, as you stated, the issue does not happen until you add Cypress to a second UI.

EDIT: I think we have to have that plugin in order to successfully run a build outside of Travis.

@tiborm
Copy link
Contributor Author

tiborm commented Mar 6, 2019

@sardell You are right. I investigated all the possible ways to extract cypress tests from the maven loop but leave the build, unit testing as it is. But no matter what we do 'npm ci' command (like you pointed out) will be executed by maven and that's going to fail if we add cypress to more than one UI project.

For now, I should close this. And hoping for some fix in the future from maven or yauzl.

@tiborm tiborm closed this Mar 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants