fabric8io / openshift-elasticsearch-plugin

Apache License 2.0
27 stars 21 forks source link

Add Elasticsearch integration tests #45

Closed lukas-vlcek closed 7 years ago

lukas-vlcek commented 8 years ago

This is WIP - DO NOT MERGE

Goals

Add integration tests with real Elasticsearch cluster. All tests will be strictly separated to unit tests and integration tests .

Unit tests will reside under src/test/* and execution will be handled by maven-surefire-plugin. Integration tests will reside under src/it/* and execution will be handled by maven-failsafe-plugin.

Tasks

lukas-vlcek commented 8 years ago

The following are some questions I would love to discuss more:

Jar Hell

I had to do some simple exclusion work in pom.xml to pass Elasticsearch Jar Hell check.

Security manager issue

Solved, see #issuecomment-312305191

Currently, when running from command line or from IDE I need to make sure Java security manager is turned off:

mvn -Dtests.security.manager=false clean test

With security manager I am running into errors like:

access denied ("java.io.FilePermission" "/Users/lvlcek/projects/lukas-vlcek/openshift-elasticsearch-plugin/src/test/resources/elasticsearch/config/admin.jks" "read")

and I do nut fully understand why. Based on this comment it seems this should be doable. I need to investigate this further. May be you have some ideas?

Generate SSL certificates on the fly

Right now, I point SG to jks files in src/test/resource/elasticsearch/config/. At this moment those files are just empty text files and my tests are failing due to this (this is expected). However, my question would be, do you think we will be able to generate these files on the fly or use some other mechanism (ideally maven friendly) to provide SSL certificates and point SG to them?

Mocking Kubernetes

If there will be need to interact with Kubernetes service during tests I hope to be able to implement mock for it (do you see any issues with this?). Heads up remined is that we might need to switch from Mockito to securemock.

jcantrill commented 8 years ago

@lukas-vlcek This plugin depends upon fabric8 implementation of kubernetes-client/openshift-client which uses okhttp. Additionally, they provide a mock library to be used for testing. I have not used it, but I believe that would allow you to mock out the back end. @jimmidyson can you point @lukas-vlcek to examples?

jimmidyson commented 8 years ago

We provide mocks for pretty much everything. Examples in the test cases in the client itself, e.g. https://github.com/fabric8io/kubernetes-client/tree/master/openshift-client/src/test/java/io/fabric8/openshift/client/mock & https://github.com/fabric8io/kubernetes-client/tree/master/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock

lukas-vlcek commented 7 years ago

ATM I still need to figure out how to configure Java security manager for integration tests. It seems Elastic developers run into the same problem. Let's see if their solution can help us.

I was able to provide Java security manager configuration just for the maven-failsafe-plugin plugin which seem to fixes the problem. Travis tests are now passing without security manager issues for both unit and integration tests!

jcantrill commented 7 years ago

closing in favor of #105