Skip to content

Commit

Permalink
Added product not supported scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
thomheymann committed Aug 30, 2021
1 parent a45adb7 commit 0f25dc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/plugins/interactive_setup/server/elasticsearch_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,16 @@ some weird+ca/with
);
});

it('fails if host is not supported', async () => {
mockPingClient.asInternalUser.ping.mockRejectedValue(
new errors.ProductNotSupportedError(interactiveSetupMock.createApiResponse({ body: {} }))
);

await expect(setupContract.ping('http://localhost:9200')).rejects.toMatchInlineSnapshot(
`[ProductNotSupportedError: The client noticed that the server is not Elasticsearch and we do not support this unknown product.]`
);
});

it('succeeds if host does not require authentication', async () => {
mockPingClient.asInternalUser.ping.mockResolvedValue(
interactiveSetupMock.createApiResponse({ statusCode: 200, body: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ export class ElasticsearchService {
try {
await client.asInternalUser.ping();
} catch (error) {
if (error instanceof errors.ConnectionError || error instanceof errors.TimeoutError) {
if (
error instanceof errors.ConnectionError ||
error instanceof errors.TimeoutError ||
error instanceof errors.ProductNotSupportedError
) {
this.logger.error(`Unable to connect to host "${host}": ${getDetailedErrorMessage(error)}`);
throw error;
}
Expand Down

0 comments on commit 0f25dc6

Please sign in to comment.