Could not running Yaml IT in my own repository plugin project

org.elasticsearch.repositories.cos.RepositoryCosClientYamlTestSuiteIT > initializationError FAILED
java.lang.NullPointerException
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.loadSuites(ESClientYamlSuiteTestCase.java:235)
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.createParameters(ESClientYamlSuiteTestCase.java:188)
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.createParameters(ESClientYamlSuiteTestCase.java:180)
    at org.elasticsearch.repositories.cos.RepositoryCosClientYamlTestSuiteIT.parameters(RepositoryCosClientYamlTestSuiteIT.java:16)


Suite: Test class org.elasticsearch.repositories.cos.RepositoryCosClientYamlTestSuiteIT
2> java.lang.NullPointerException
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.loadSuites(ESClientYamlSuiteTestCase.java:235)
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.createParameters(ESClientYamlSuiteTestCase.java:188)
    at org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase.createParameters(ESClientYamlSuiteTestCase.java:180)
    at org.elasticsearch.repositories.cos.RepositoryCosClientYamlTestSuiteIT.parameters(RepositoryCosClientYamlTestSuiteIT.java:16)

1 test completed, 1 failed

I wrote my own YamlTestSuitIT class and could not runing in my own plugin project. As it's showed in the error msg, I guess the reason is that the ES test files rest-api-spec was not including in the jar package.

Is there any good ideas for running YamlTestSuiteIT out side the ES project?

can you share the directory structure of your project, especially the test directory?

package org.elasticsearch.repositories.cos;

import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;

public class RepositoryCosClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {

    public RepositoryCosClientYamlTestSuiteIT(@Name("yaml")ClientYamlTestCandidate testCandidate) {
        super(testCandidate);
    }

    @ParametersFactory
    public static Iterable<Object[]> parameters() throws Exception {
        return ESClientYamlSuiteTestCase.createParameters();
    }
}

please use something on the command line like tree to show this, as I now still don't know how the directory structure looks like, just like intellij is showing it :slight_smile:

I'm especially interested where your .yml files are placed exactly.

the rest-api-spec directory should not contain dots, but have subdirectories like test/resources/rest-api-spec/test/repository_cos/10_basic.yml

cool, it works. thx Alex:+1:t2:

1 Like

Alex, another question :joy:

I wrote my own rest-api-spec above, and I want to replace the ${} from in gradle build

  processTestResources {
  Map<String, Object> expansions = [
        'bucket': cosBucket,
        'base_path': cosBasePath,
 ]
 inputs.properties(expansions)
 MavenFilteringHack.filter(it, expansions)

}

And How can I use MavenFilteringHack with my own rest-api-spec yaml file?

this is what is done in the s3 repository plugin tests as well. Can you also share the error, maybe someone with more plugin expertise than me will take a look.

https://discuss.elastic.co/t/how-to-use-mavenfilteringhack-to-replace-var-from-yaml-files/209959

THX, I create a new topic

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.