@@ -0,0 +1,2263 @@
+/*%0A * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one%0A * or more contributor license agreements. Licensed under the Elastic License;%0A * you may not use this file except in compliance with the Elastic License.%0A */%0Apackage org.elasticsearch.xpack.qa.sql.nosecurity;%0A%0Aimport org.elasticsearch.client.Request;%0Aimport org.elasticsearch.xpack.qa.sql.jdbc.JdbcIntegrationTestCase;%0Aimport org.junit.Before;%0A%0Aimport java.io.IOException;%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0A%0Aimport static org.hamcrest.Matchers.containsString;%0A%0Apublic class JdbcShardFailureIT extends JdbcIntegrationTestCase %7B%0A    @Before%0A    public void createTestIndex() throws IOException %7B%0A        Request createTest1 = new Request(%22PUT%22, %22/test1%22);%0A        String body1 = %22%7B%5C%22aliases%5C%22:%7B%5C%22test%5C%22:%7B%7D%7D, %5C%22mappings%5C%22: %7B%5C%22doc%5C%22: %7B%5C%22properties%5C%22: %7B%5C%22test_field%5C%22:%7B%5C%22type%5C%22:%5C%22integer%5C%22%7D%7D%7D%7D%7D%22;%0A        createTest1.setJsonEntity(body1);%0A        client().performRequest(createTest1);%0A%0A        Request createTest2 = new Request(%22PUT%22, %22/test2%22);%0A        String body2 = %22%7B%5C%22aliases%5C%22:%7B%5C%22test%5C%22:%7B%7D%7D, %5C%22mappings%5C%22: %7B%5C%22doc%5C%22: %7B%5C%22properties%5C%22: %7B%5C%22test_field%5C%22:%7B%5C%22type%5C%22:%5C%22integer%5C%22%7D%7D%7D%7D,%22 +%0A            %22%5C%22settings%5C%22: %7B%5C%22index.routing.allocation.include.node%5C%22: %5C%22nowhere%5C%22%7D%7D%22;%0A        createTest2.setJsonEntity(body2);%0A        createTest2.addParameter(%22timeout%22, %22100ms%22);%0A        client().performRequest(createTest2);%0A%0A        Request request = new Request(%22PUT%22, %22/test1/doc/_bulk%22);%0A        request.addParameter(%22refresh%22, %22true%22);%0A        StringBuilder bulk = new StringBuilder();%0A        for (int i = 0; i %3C 20; i++) %7B%0A            bulk.append(%22%7B%5C%22index%5C%22:%7B%7D%7D%5Cn%22);%0A            bulk.append(%22%7B%5C%22test_field%5C%22:%22 + i + %22%7D%5Cn%22);%0A        %7D%0A        request.setJsonEntity(bulk.toString());%0A        client().performRequest(request);%0A    %7D%0A%0A    public void testPartialResponseHandling() throws SQLException %7B%0A        try (Connection c = esJdbc(); Statement s = c.createStatement()) %7B%0A            SQLException exception = expectThrows(SQLException.class, () -%3E s.executeQuery(%22SELECT * FROM test ORDER BY test_field ASC%22));%0A            assertThat(exception.getMessage(), containsString(%22Search rejected due to missing shards%22));%0A        %7D%0A    %7D%0A%7D%0A

Add test for handling of partial results (#32474)