fabric8io / openshift-elasticsearch-plugin

Apache License 2.0
27 stars 21 forks source link

Dead code with side effect in test OpenshiftAPIServiceTest #167

Open barkbay opened 5 years ago

barkbay commented 5 years ago

It looks like there is some dead code here :

    @Before
    public void setup() {
        final String basedir = System.getProperty("project.basedir");
        final String password = "changeit";
        final String keyStore = basedir + "/src/it/resources/keystore.jks";
        [...]
        System.setProperty("kubernetes.keystore.file", keyStore);
        [...]
}

System.getProperty("project.basedir") always returns null and the system property kubernetes.keystore.file is always set to null/src/it/resources/keystore.jks Please also note that tests are not failing if you delete the file src/it/resources/keystore.jks, so it looks like this file is not used too.

Looking at the pom.xml I guess that the first idea was to use the environment variable PROJECT_DIR :

...
                    <environmentVariables>
                        <ENV_VAR_EXISTS>value</ENV_VAR_EXISTS>
                        <ENV_VAR_EXISTS_BOOLEAN>true</ENV_VAR_EXISTS_BOOLEAN>
                        <PROJECT_DIR>${project.basedir}</PROJECT_DIR>
                    </environmentVariables>
...

System.getProperty("project.basedir") should be replaced with System.getenv("PROJECT_DIR")

The problem is that by setting a wrong system property with System.setProperty("..") without further cleanup with a @After it has some side effects on other piece of code.

barkbay commented 5 years ago

This issue blocks #111

jcantrill commented 5 years ago

@barkbay please feel free to submit a pull request.