Skip to content

Commit

Permalink
Merge 'main' into lucene_snapshot_9_9
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed Dec 4, 2023
2 parents 4cf6f30 + af30fe4 commit 605c76e
Show file tree
Hide file tree
Showing 35 changed files with 1,750 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"connector.update_error": {
"documentation": {
"url": "https://www.elastic.co/guide/en/enterprise-search/current/connectors.html",
"description": "Updates the error field in the connector document."
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.connector_api_feature_flag_enabled",
"headers": {
"accept": [
"application/json"
],
"content_type": [
"application/json"
]
},
"url": {
"paths": [
{
"path": "/_connector/{connector_id}/_error",
"methods": [
"PUT"
],
"parts": {
"connector_id": {
"type": "string",
"description": "The unique identifier of the connector to be updated."
}
}
}
]
},
"body": {
"description": "An object containing the connector's error.",
"required": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"connector_sync_job.get": {
"documentation": {
"url": "https://www.elastic.co/guide/en/enterprise-search/current/connectors.html",
"description": "Returns the details about a connector sync job."
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.connector_api_feature_flag_enabled",
"headers": {
"accept": [
"application/json"
]
},
"url": {
"paths": [
{
"path": "/_connector/_sync_job/{connector_sync_job_id}",
"methods": [
"GET"
],
"parts": {
"connector_sync_job_id": {
"type": "string",
"description": "The unique identifier of the connector sync job to be returned."
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.CancellableThreadsTests;
Expand Down Expand Up @@ -129,9 +128,8 @@

public class ExceptionSerializationTests extends ESTestCase {

public void testExceptionRegistration() throws ClassNotFoundException, IOException, URISyntaxException {
public void testExceptionRegistration() throws IOException, URISyntaxException {
final Set<Class<?>> notRegistered = new HashSet<>();
final Set<Class<?>> hasDedicatedWrite = new HashSet<>();
final Set<Class<?>> registered = new HashSet<>();
final String path = "/org/elasticsearch";
final Path startPath = PathUtils.get(ElasticsearchException.class.getProtectionDomain().getCodeSource().getLocation().toURI())
Expand All @@ -146,13 +144,13 @@ public void testExceptionRegistration() throws ClassNotFoundException, IOExcepti
private Path pkgPrefix = PathUtils.get(path).getParent();

@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
pkgPrefix = pkgPrefix.resolve(dir.getFileName());
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
checkFile(file.getFileName().toString());
return FileVisitResult.CONTINUE;
}
Expand Down Expand Up @@ -180,13 +178,6 @@ private void checkClass(Class<?> clazz) {
notRegistered.add(clazz);
} else if (ElasticsearchException.isRegistered(clazz.asSubclass(Throwable.class), TransportVersion.current())) {
registered.add(clazz);
try {
if (clazz.getMethod("writeTo", StreamOutput.class) != null) {
hasDedicatedWrite.add(clazz);
}
} catch (Exception e) {
// fair enough
}
}
}

Expand All @@ -199,7 +190,7 @@ private Class<?> loadClass(String filename) throws ClassNotFoundException {
for (Path p : pkgPrefix) {
pkg.append(p.getFileName().toString()).append(".");
}
pkg.append(filename.substring(0, filename.length() - 6));
pkg.append(filename, 0, filename.length() - 6);
return getClass().getClassLoader().loadClass(pkg.toString());
}

Expand All @@ -209,7 +200,7 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
}

@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
pkgPrefix = pkgPrefix.getParent();
return FileVisitResult.CONTINUE;
}
Expand All @@ -220,7 +211,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
Files.walkFileTree(testStartPath, visitor);
assertTrue(notRegistered.remove(TestException.class));
assertTrue(notRegistered.remove(UnknownHeaderException.class));
assertTrue("Classes subclassing ElasticsearchException must be registered \n" + notRegistered.toString(), notRegistered.isEmpty());
assertTrue("Classes subclassing ElasticsearchException must be registered \n" + notRegistered, notRegistered.isEmpty());
assertTrue(registered.removeAll(ElasticsearchException.getRegisteredKeys())); // check
assertEquals(registered.toString(), 0, registered.size());
}
Expand Down Expand Up @@ -344,7 +335,7 @@ public void testInvalidIndexTemplateException() throws IOException {
assertEquals(ex.name(), "foo");
ex = serialize(new InvalidIndexTemplateException(null, "bar"));
assertEquals(ex.getMessage(), "index_template [null] invalid, cause [bar]");
assertEquals(ex.name(), null);
assertNull(ex.name());
}

public void testActionTransportException() throws IOException {
Expand All @@ -353,17 +344,12 @@ public void testActionTransportException() throws IOException {
assertEquals("[name?][" + transportAddress + "][ACTION BABY!] message?", ex.getMessage());
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/102868")
public void testSearchContextMissingException() throws IOException {
ShardSearchContextId contextId = new ShardSearchContextId(UUIDs.randomBase64UUID(), randomLong());
TransportVersion version = TransportVersionUtils.randomVersion(random());
TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random());
SearchContextMissingException ex = serialize(new SearchContextMissingException(contextId), version);
assertThat(ex.contextId().getId(), equalTo(contextId.getId()));
if (version.onOrAfter(TransportVersions.V_7_7_0)) {
assertThat(ex.contextId().getSessionId(), equalTo(contextId.getSessionId()));
} else {
assertThat(ex.contextId().getSessionId(), equalTo(""));
}
assertThat(ex.contextId().getSessionId(), equalTo(contextId.getSessionId()));
}

public void testCircuitBreakingException() throws IOException {
Expand Down Expand Up @@ -422,7 +408,7 @@ public void testConnectTransportException() throws IOException {
}

public void testSearchPhaseExecutionException() throws IOException {
ShardSearchFailure[] empty = new ShardSearchFailure[0];
ShardSearchFailure[] empty = ShardSearchFailure.EMPTY_ARRAY;
SearchPhaseExecutionException ex = serialize(new SearchPhaseExecutionException("boom", "baam", new NullPointerException(), empty));
assertEquals("boom", ex.getPhaseName());
assertEquals("baam", ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public enum FeatureFlag {
TIME_SERIES_MODE("es.index_mode_feature_flag_registered=true", Version.fromString("8.0.0"), null),
INFERENCE_RESCORER("es.inference_rescorer_feature_flag_enabled=true", Version.fromString("8.10.0"), null),
LEARN_TO_RANK("es.learn_to_rank_feature_flag_enabled=true", Version.fromString("8.10.0"), null),
FAILURE_STORE_ENABLED("es.failure_store_feature_flag_enabled=true", Version.fromString("8.12.0"), null);

public final String systemProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
setup:
- skip:
version: " - 8.11.99"
reason: Introduced in 8.12.0

- do:
connector.put:
connector_id: test-connector
body:
index_name: search-1-test
name: my-connector
language: pl
is_native: false
service_type: super-connector

---
"Update Connector Error":
- do:
connector.update_error:
connector_id: test-connector
body:
error: "some error"


- match: { result: updated }

- do:
connector.get:
connector_id: test-connector

- match: { error: "some error" }

---
"Update Connector Error - 404 when connector doesn't exist":
- do:
catch: "missing"
connector.update_error:
connector_id: test-non-existent-connector
body:
error: "some error"

---
"Update Connector Error - 400 status code when connector_id is empty":
- do:
catch: "bad_request"
connector.update_error:
connector_id: ""
body:
error: "some error"

---
"Update Connector Error - 400 status code when payload is not string":
- do:
catch: "bad_request"
connector.update_error:
connector_id: test-connector
body:
error:
field_1: test
field_2: something
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
setup:
- skip:
version: " - 8.11.99"
reason: Introduced in 8.12.0
- do:
connector.put:
connector_id: test-connector
body:
index_name: search-test
name: my-connector
language: de
is_native: false
service_type: super-connector

---
'Get connector sync job':
- do:
connector_sync_job.post:
body:
id: test-connector
job_type: access_control
trigger_method: scheduled
- set: { id: id }
- match: { id: $id }
- do:
connector_sync_job.get:
connector_sync_job_id: $id
- match: { job_type: access_control }
- match: { trigger_method: scheduled }

---
'Get connector sync job - Missing sync job id':
- do:
connector_sync_job.get:
connector_sync_job_id: non-existing-sync-job-id
catch: missing
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.elasticsearch.xpack.application.connector.action.RestGetConnectorAction;
import org.elasticsearch.xpack.application.connector.action.RestListConnectorAction;
import org.elasticsearch.xpack.application.connector.action.RestPutConnectorAction;
import org.elasticsearch.xpack.application.connector.action.RestUpdateConnectorErrorAction;
import org.elasticsearch.xpack.application.connector.action.RestUpdateConnectorFilteringAction;
import org.elasticsearch.xpack.application.connector.action.RestUpdateConnectorLastSeenAction;
import org.elasticsearch.xpack.application.connector.action.RestUpdateConnectorLastSyncStatsAction;
Expand All @@ -59,11 +60,13 @@
import org.elasticsearch.xpack.application.connector.action.TransportGetConnectorAction;
import org.elasticsearch.xpack.application.connector.action.TransportListConnectorAction;
import org.elasticsearch.xpack.application.connector.action.TransportPutConnectorAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorErrorAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorFilteringAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorLastSeenAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorLastSyncStatsAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorPipelineAction;
import org.elasticsearch.xpack.application.connector.action.TransportUpdateConnectorSchedulingAction;
import org.elasticsearch.xpack.application.connector.action.UpdateConnectorErrorAction;
import org.elasticsearch.xpack.application.connector.action.UpdateConnectorFilteringAction;
import org.elasticsearch.xpack.application.connector.action.UpdateConnectorLastSeenAction;
import org.elasticsearch.xpack.application.connector.action.UpdateConnectorLastSyncStatsAction;
Expand All @@ -72,14 +75,17 @@
import org.elasticsearch.xpack.application.connector.syncjob.action.CancelConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.CheckInConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.DeleteConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.GetConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.PostConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.RestCancelConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.RestCheckInConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.RestDeleteConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.RestGetConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.RestPostConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.TransportCancelConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.TransportCheckInConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.TransportDeleteConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.TransportGetConnectorSyncJobAction;
import org.elasticsearch.xpack.application.connector.syncjob.action.TransportPostConnectorSyncJobAction;
import org.elasticsearch.xpack.application.rules.QueryRulesConfig;
import org.elasticsearch.xpack.application.rules.QueryRulesIndexService;
Expand Down Expand Up @@ -201,13 +207,15 @@ protected XPackLicenseState getLicenseState() {
new ActionHandler<>(GetConnectorAction.INSTANCE, TransportGetConnectorAction.class),
new ActionHandler<>(ListConnectorAction.INSTANCE, TransportListConnectorAction.class),
new ActionHandler<>(PutConnectorAction.INSTANCE, TransportPutConnectorAction.class),
new ActionHandler<>(UpdateConnectorErrorAction.INSTANCE, TransportUpdateConnectorErrorAction.class),
new ActionHandler<>(UpdateConnectorFilteringAction.INSTANCE, TransportUpdateConnectorFilteringAction.class),
new ActionHandler<>(UpdateConnectorLastSeenAction.INSTANCE, TransportUpdateConnectorLastSeenAction.class),
new ActionHandler<>(UpdateConnectorLastSyncStatsAction.INSTANCE, TransportUpdateConnectorLastSyncStatsAction.class),
new ActionHandler<>(UpdateConnectorPipelineAction.INSTANCE, TransportUpdateConnectorPipelineAction.class),
new ActionHandler<>(UpdateConnectorSchedulingAction.INSTANCE, TransportUpdateConnectorSchedulingAction.class),

// SyncJob API
new ActionHandler<>(GetConnectorSyncJobAction.INSTANCE, TransportGetConnectorSyncJobAction.class),
new ActionHandler<>(PostConnectorSyncJobAction.INSTANCE, TransportPostConnectorSyncJobAction.class),
new ActionHandler<>(DeleteConnectorSyncJobAction.INSTANCE, TransportDeleteConnectorSyncJobAction.class),
new ActionHandler<>(CheckInConnectorSyncJobAction.INSTANCE, TransportCheckInConnectorSyncJobAction.class),
Expand Down Expand Up @@ -267,13 +275,15 @@ public List<RestHandler> getRestHandlers(
new RestGetConnectorAction(),
new RestListConnectorAction(),
new RestPutConnectorAction(),
new RestUpdateConnectorErrorAction(),
new RestUpdateConnectorFilteringAction(),
new RestUpdateConnectorLastSeenAction(),
new RestUpdateConnectorLastSyncStatsAction(),
new RestUpdateConnectorPipelineAction(),
new RestUpdateConnectorSchedulingAction(),

// SyncJob API
new RestGetConnectorSyncJobAction(),
new RestPostConnectorSyncJobAction(),
new RestDeleteConnectorSyncJobAction(),
new RestCancelConnectorSyncJobAction(),
Expand Down
Loading

0 comments on commit 605c76e

Please sign in to comment.