You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by merrimanr <gi...@git.apache.org> on 2018/02/22 22:15:09 UTC

[GitHub] metron pull request #941: METRON-1355: Convert metron-elasticsearch to new i...

GitHub user merrimanr opened a pull request:

    https://github.com/apache/metron/pull/941

    METRON-1355: Convert metron-elasticsearch to new infrastructure

    ## Contributor Comments
    This PR switches metron-elasticsearch integration tests from using in-memory components to the e2e Docker infrastructure.  A high-level summary of the changes:
    
    - Updated travis to only run the metron-elasticsearch tests
    - Updated the Elasticsearch Docker image to the same version as Metron
    - Removed the requirement to build a base "metron-centos" image.  Removes an extra Docker build step and I'm not sure caching this helps much anyways.
    - Updated each integration test to use index names that are namespaced with the test class name
    - Replaced the in-memory component setup with an Elasticsearch client configured for the Elasticsearch Docker container
    - Added steps to setup/delete indices before/after each test
    - Moved Elasticsearch in-memory helper methods and common integration tests methods to a utils class
    - Fixed a minor bug in the ElasticsearchMetaAlertDao class where the index is always hardcoded to "metaalert"
    - Added some initial documentation for the metron-docker-e2e module
    
    The scope of this PR are 3 of the 4 metron-elasticsearch integration tests:
    
    - org.apache.metron.elasticsearch.integration.ElasticsearchMetaAlertIntegrationTest
    - org.apache.metron.elasticsearch.integration.ElasticsearchSearchIntegrationTest
    - org.apache.metron.elasticsearch.integration.ElasticsearchUpdateIntegrationTest
    
    Most of the test logic in org.apache.metron.elasticsearch.integration.ElasticsearchIndexingIntegrationTest is actually in metron-indexing so that test will be updated when we convert that module.
    
    At this point only the metron-elasticsearch tests are run in travis.  My plan is to slowly add tests for each module until we reach feature parity with master.  At that point the "install" section of .travis.yml will be the same.  The alerts ui e2e tests were removed for now until the work being done to stabilize them is complete.
    
    The ES in-memory component starts up pretty fast so performance improved for the 3 tests by about 7 seconds.  Curious to hear what people think.
    
    ## Pull Request Checklist
    
    Thank you for submitting a contribution to Apache Metron.  
    Please refer to our [Development Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235) for the complete guide to follow for contributions.  
    Please refer also to our [Build Verification Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview) 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:
    - [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
    - [x] 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.
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    
    ### For code changes:
    - [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
    - [x] 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 
      ```
    
    - [x] Have you written or updated unit tests and or integration tests to verify your changes?
    - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
    - [ ] 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](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/merrimanr/incubator-metron METRON-1355

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/941.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #941
    
----
commit a5fc2a1aa11616591227e8ce950e672df2694698
Author: merrimanr <me...@...>
Date:   2018-02-20T22:13:25Z

    Merge remote-tracking branch 'mirror/master' into feature/METRON-1344-test-infrastructure
    
    # Conflicts:
    #	.travis.yml
    #	metron-interface/metron-alerts/e2e/utils/e2e_util.ts
    #	metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchSearchIntegrationTest.java
    #	metron-platform/metron-indexing/src/test/java/org/apache/metron/indexing/dao/SearchIntegrationTest.java

commit 14a573f7743c9be92f852284a1a859c24cb117ae
Author: merrimanr <me...@...>
Date:   2018-02-22T17:31:59Z

    initial commit

commit 09c8193b2dc71d37f3e1730f83053e3f196b2d2b
Author: merrimanr <me...@...>
Date:   2018-02-22T18:06:54Z

    wait for ES container to come up

commit 1b40e51ca89728647b668e051c67ac1e21abb367
Author: merrimanr <me...@...>
Date:   2018-02-22T20:20:00Z

    Merge remote-tracking branch 'mirror/feature/METRON-1344-test-infrastructure' into METRON-1355
    
    # Conflicts:
    #	.travis.yml
    #	metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchSearchIntegrationTest.java
    #	metron-platform/metron-indexing/src/test/java/org/apache/metron/indexing/dao/SearchIntegrationTest.java

----


---

[GitHub] metron issue #941: METRON-1355: Convert metron-elasticsearch to new infrastr...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/941
  
    No, that can wait for the follow-on ticket.  Could you add a quick one-sentence blurb about the ElasticsearchTestUtils in the README so things are easier for anyone to test later (with the knowledge that it'll drop out in the later ticket)?


---

[GitHub] metron pull request #941: METRON-1355: Convert metron-elasticsearch to new i...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr closed the pull request at:

    https://github.com/apache/metron/pull/941


---

[GitHub] metron issue #941: METRON-1355: Convert metron-elasticsearch to new infrastr...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/941
  
    I'm unable to get the integration tests running locally.  I've been able to get the docker containers up and running, but ES isn't exposed at localhost, only through the explicit docker-machine ip.  This causes the integration tests to fail, as they are unable to successfully query against ES.
    Any idea why this is happening? Am I missing an env config or something?
    
    Also, is it worthwhile to wrap most of the setup in a script? There's enough steps that have to be taken that I'd really like a script that's just "setup_integration_env.sh".  Extra credit if it can be rolled into the maven build such that it just automagically takes care of it when we run the maven integration test target (or it's run by install or whatever).  It would be super nice if we didn't have to worry about anything other than just running the maven target.
    
    Regardless of what wrapping we do, it would be really nice to clean some stuff up so the integration test instructions become a one-shot "Here's the step by step". Right now, I had to look at the Travis run to figure out (remember) the semi-odd way we split unit and integration test calls in maven, etc.


---

[GitHub] metron pull request #941: METRON-1355: Convert metron-elasticsearch to new i...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on a diff in the pull request:

    https://github.com/apache/metron/pull/941#discussion_r172318991
  
    --- Diff: metron-contrib/metron-docker-e2e/README.md ---
    @@ -0,0 +1,94 @@
    +<!--
    +Licensed to the Apache Software Foundation (ASF) under one
    +or more contributor license agreements.  See the NOTICE file
    +distributed with this work for additional information
    +regarding copyright ownership.  The ASF licenses this file
    +to you under the Apache License, Version 2.0 (the
    +"License"); you may not use this file except in compliance
    +with the License.  You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +-->
    +# Metron Docker
    +
    +Metron Docker E2E is a [Docker Compose](https://docs.docker.com/compose/overview/) application that serves as a backend to integration tests.
    +
    +Metron Docker includes these images that have been customized for Metron:
    +
    +  - Kafka
    +  - Zookeeper
    +  - Elasticsearch
    +  - Metron REST
    +  - Metron UIs
    +
    +Setup
    +-----
    +
    +Install [Docker for Mac](https://docs.docker.com/docker-for-mac/) or [Docker for Windows](https://docs.docker.com/docker-for-windows/).  The following versions have been tested:
    +
    +  - Docker version 17.12.0-ce
    +  - docker-machine version 0.13.0
    +  - docker-compose version 1.18.0
    +
    +Build Metron from the top level directory with:
    +```
    +$ cd $METRON_HOME
    +$ mvn clean install -DskipTests
    +```
    +
    +Create a Docker machine:
    +```
    +$ export METRON_DOCKER_E2E_HOME=$METRON_HOME/metron-contrib/metron-docker-e2e
    +$ cd $METRON_DOCKER_E2E_HOME
    +$ ./scripts/create-docker-machine.sh
    +```
    +
    +This will create a host called "metron-machine".  Anytime you want to run Docker commands against this host, make sure you run this first to set the Docker environment variables:
    +```
    +$ eval "$(docker-machine env metron-machine)"
    +```
    +
    +If you wish to use a local docker-engine install, please set an environment variable BROKER_IP_ADDR to the IP address of your host machine. This cannot be the loopback address.
    +
    +Usage
    +-----
    +
    +Navigate to the compose application root:
    +```
    +$ cd $METRON_DOCKER_E2E_HOME/compose/
    +```
    +
    +The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command.  The service names can be found in the docker-compose.yml file.  For example, to build and start the environment run this command:
    +```
    +$ eval "$(docker-machine env metron-machine)"
    +$ docker-compose up -d
    +```
    +
    +After all services have started list the containers and ensure their status is 'Up':
    +```
    +$ docker-compose ps
    +         Name                       Command               State                       Ports                     
    +----------------------------------------------------------------------------------------------------------------
    +metron_elasticsearch_1   /bin/bash bin/es-docker          Up      0.0.0.0:9210->9200/tcp, 0.0.0.0:9310->9300/tcp
    +metron_kafka_1           start-kafka.sh                   Up      0.0.0.0:9092->9092/tcp                        
    +metron_metron-rest_1     /bin/sh -c ./bin/start.sh        Up      0.0.0.0:8082->8082/tcp                        
    +metron_metron-ui_1       /bin/sh -c ./bin/start.sh        Up      0.0.0.0:4201->4201/tcp                        
    +metron_zookeeper_1       /docker-entrypoint.sh zkSe ...   Up      0.0.0.0:2181->2181/tcp, 2888/tcp, 3888/tcp    
    +```
    +
    +Various services are exposed through http on the Docker host.  Get the host ip from the URL property:
    +```
    +$ docker-machine ls
    +NAME             ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
    +metron-machine   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.5
    +```
    +
    +The various integration tests can now be run against this environment.
    +
    +TODO: document how to set docker machine ip address for e2e tests
    --- End diff --
    
    Looks like a leftover TODO.  Would you mind adding this info?


---

[GitHub] metron issue #941: METRON-1355: Convert metron-elasticsearch to new infrastr...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/941
  
    +1, thanks for the contribution.  Glad to see this making progress, it's definitely valuable.


---

[GitHub] metron issue #941: METRON-1355: Convert metron-elasticsearch to new infrastr...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:

    https://github.com/apache/metron/pull/941
  
    Sorry I should have documented this better in the PR description.  The docker-machine ip address needs to be substituted in ElasticsearchTestUtils temporarily if you want to run this on your local Mac OS.  There is a Jira for this work here:  https://issues.apache.org/jira/browse/METRON-1356.  Everything you've described including the TODO is intended to be handled there.  Do you think that needs to come first before you review this PR?  


---