Search in sources :

Example 1 with ClientYamlTestSection

use of org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection in project elasticsearch by elastic.

the class ESClientYamlSuiteTestCase method collectTestCandidates.

private static List<ClientYamlTestCandidate> collectTestCandidates() throws IOException {
    List<ClientYamlTestCandidate> testCandidates = new ArrayList<>();
    FileSystem fileSystem = getFileSystem();
    // ... and you can't close() the default filesystem
    try {
        String[] paths = resolvePathsProperty(REST_TESTS_SUITE, DEFAULT_TESTS_PATH);
        Map<String, Set<Path>> yamlSuites = FileUtils.findYamlSuites(fileSystem, DEFAULT_TESTS_PATH, paths);
        //yaml suites are grouped by directory (effectively by api)
        for (String api : yamlSuites.keySet()) {
            List<Path> yamlFiles = new ArrayList<>(yamlSuites.get(api));
            for (Path yamlFile : yamlFiles) {
                ClientYamlTestSuite restTestSuite = ClientYamlTestSuite.parse(api, yamlFile);
                for (ClientYamlTestSection testSection : restTestSuite.getTestSections()) {
                    testCandidates.add(new ClientYamlTestCandidate(restTestSuite, testSection));
                }
            }
        }
    } finally {
        IOUtils.close(fileSystem);
    }
    //sort the candidates so they will always be in the same order before being shuffled, for repeatability
    Collections.sort(testCandidates, (o1, o2) -> o1.getTestPath().compareTo(o2.getTestPath()));
    return testCandidates;
}
Also used : Path(java.nio.file.Path) Set(java.util.Set) ClientYamlTestSection(org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection) FileSystem(java.nio.file.FileSystem) ArrayList(java.util.ArrayList) ClientYamlTestSuite(org.elasticsearch.test.rest.yaml.section.ClientYamlTestSuite)

Aggregations

FileSystem (java.nio.file.FileSystem)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 ClientYamlTestSection (org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection)1 ClientYamlTestSuite (org.elasticsearch.test.rest.yaml.section.ClientYamlTestSuite)1