Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remote clusters] Add support for proxy mode #59221

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4fd3714
init commit: support for proxy mode
alisonelizabeth Mar 3, 2020
a876d52
fix edit remote clusters
alisonelizabeth Mar 4, 2020
884731f
add proxy support in details panel
alisonelizabeth Mar 4, 2020
bd28e2f
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 5, 2020
df590e3
update table
alisonelizabeth Mar 6, 2020
41a4397
fix validation
alisonelizabeth Mar 6, 2020
d84337d
cleanup: update tests, remove unused translations, add proxy badge
alisonelizabeth Mar 6, 2020
56671ca
fix ccr test
alisonelizabeth Mar 9, 2020
e7aead7
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 9, 2020
ecf78ff
update api tests
alisonelizabeth Mar 9, 2020
3fa3cb4
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 11, 2020
cbde9d1
add support for deprecated setting; add support for server_name
alisonelizabeth Mar 11, 2020
de6393b
add documentation link
alisonelizabeth Mar 11, 2020
dcd5044
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 12, 2020
5a260c6
update tests
alisonelizabeth Mar 12, 2020
760073e
add callout to details panel for deprecated proxy setting
alisonelizabeth Mar 13, 2020
eba69a6
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 13, 2020
0c582ab
cleanup and test fixes
alisonelizabeth Mar 13, 2020
1bb3b62
cleanup detail panel logic
alisonelizabeth Mar 13, 2020
4fe853f
update jest snapshot
alisonelizabeth Mar 13, 2020
95b2c96
Merge branch 'master' of github.com:elastic/kibana into feature/remot…
alisonelizabeth Mar 16, 2020
91cd33c
address review feedback
alisonelizabeth Mar 16, 2020
ca41b5f
update jest snapshots
alisonelizabeth Mar 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ describe('Create Remote cluster', () => {
expect(find('remoteClusterFormSkipUnavailableFormToggle').props()['aria-checked']).toBe(true);
});

test('should have a toggle to enable "proxy" mode for a remote cluster', () => {
expect(exists('remoteClusterFormConnectionModeToggle')).toBe(true);

// By default it should be set to "false"
expect(find('remoteClusterFormConnectionModeToggle').props()['aria-checked']).toBe(false);

form.toggleEuiSwitch('remoteClusterFormConnectionModeToggle');

expect(find('remoteClusterFormConnectionModeToggle').props()['aria-checked']).toBe(true);
});

test('should display errors and disable the save button when clicking "save" without filling the form', () => {
expect(exists('remoteClusterFormGlobalError')).toBe(false);
expect(find('remoteClusterFormSaveButton').props().disabled).toBe(false);
Expand Down Expand Up @@ -144,5 +155,44 @@ describe('Create Remote cluster', () => {
expect(form.getErrorsMessages()).toContain('A port is required.');
});
});

describe('proxy address', () => {
let actions;
let form;

beforeEach(async () => {
({ form, actions } = setup());

// Enable "proxy" mode
form.toggleEuiSwitch('remoteClusterFormConnectionModeToggle');
});

test('should only allow alpha-numeric characters and "-" (dash) in the proxy address "host" part', () => {
actions.clickSaveForm(); // display form errors

const notInArray = array => value => array.indexOf(value) < 0;

const expectInvalidChar = char => {
form.setInputValue('remoteClusterFormProxyAddressInput', `192.16${char}:3000`);
expect(form.getErrorsMessages()).toContain(
'Address must use host:port format. Example: 127.0.0.1:9400, localhost:9400. Hosts can only consist of letters, numbers, and dashes.'
);
};

[...NON_ALPHA_NUMERIC_CHARS, ...ACCENTED_CHARS]
.filter(notInArray(['-', '_', ':']))
.forEach(expectInvalidChar);
});

test('should require a numeric "port" to be set', () => {
actions.clickSaveForm();

form.setInputValue('remoteClusterFormProxyAddressInput', '192.168.1.1');
expect(form.getErrorsMessages()).toContain('A port is required.');

form.setInputValue('remoteClusterFormProxyAddressInput', '192.168.1.1:abc');
expect(form.getErrorsMessages()).toContain('A port is required.');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { getRouter } from '../../public/application/services';
import { getRemoteClusterMock } from '../../fixtures/remote_cluster';

import { PROXY_MODE } from '../../common/constants';

jest.mock('ui/new_platform');

const { setup } = pageHelpers.remoteClustersList;
Expand Down Expand Up @@ -84,12 +86,26 @@ describe('<RemoteClusterList />', () => {
const remoteCluster2 = getRemoteClusterMock({
name: `b${getRandomString()}`,
isConnected: false,
connectedNodesCount: 0,
seeds: ['localhost:9500'],
connectedSocketsCount: 0,
proxyAddress: 'localhost:9500',
isConfiguredByNode: true,
mode: PROXY_MODE,
seeds: null,
connectedNodesCount: null,
});
const remoteCluster3 = getRemoteClusterMock({
name: `c${getRandomString()}`,
isConnected: false,
connectedSocketsCount: 0,
proxyAddress: 'localhost:9500',
isConfiguredByNode: false,
mode: PROXY_MODE,
hasDeprecatedProxySetting: true,
seeds: null,
connectedNodesCount: null,
});

const remoteClusters = [remoteCluster1, remoteCluster2];
const remoteClusters = [remoteCluster1, remoteCluster2, remoteCluster3];

beforeEach(async () => {
httpRequestsMockHelpers.setLoadRemoteClustersResponse(remoteClusters);
Expand Down Expand Up @@ -118,17 +134,28 @@ describe('<RemoteClusterList />', () => {
[
'', // Empty because the first column is the checkbox to select the row
remoteCluster1.name,
remoteCluster1.seeds.join(', '),
'Connected',
'default',
remoteCluster1.seeds.join(', '),
remoteCluster1.connectedNodesCount.toString(),
'', // Empty because the last column is for the "actions" on the resource
],
[
'',
remoteCluster2.name,
remoteCluster2.seeds.join(', '),
'Not connected',
remoteCluster2.connectedNodesCount.toString(),
PROXY_MODE,
remoteCluster2.proxyAddress,
remoteCluster2.connectedSocketsCount.toString(),
'',
],
[
'',
remoteCluster3.name,
'Not connected',
PROXY_MODE,
remoteCluster2.proxyAddress,
remoteCluster2.connectedSocketsCount.toString(),
'',
],
]);
Expand All @@ -141,6 +168,14 @@ describe('<RemoteClusterList />', () => {
).toBe(1);
});

test('should have a tooltip to indicate that the cluster has a deprecated setting', () => {
const secondRow = rows[2].reactWrapper; // The third cluster has been defined with deprecated setting
expect(
findTestSubject(secondRow, 'remoteClustersTableListClusterWithDeprecatedSettingTooltip')
.length
).toBe(1);
});

describe('bulk delete button', () => {
test('should be visible when a remote cluster is selected', () => {
expect(exists('remoteClusterBulkDeleteButton')).toBe(false);
Expand Down Expand Up @@ -199,8 +234,8 @@ describe('<RemoteClusterList />', () => {
errors: [],
});

// Make sure that we have our 2 remote clusters in the table
expect(rows.length).toBe(2);
// Make sure that we have our 3 remote clusters in the table
expect(rows.length).toBe(3);

actions.selectRemoteClusterAt(0);
actions.clickBulkDeleteButton();
Expand All @@ -211,7 +246,7 @@ describe('<RemoteClusterList />', () => {

({ rows } = table.getMetaData('remoteClusterListTable'));

expect(rows.length).toBe(1);
expect(rows.length).toBe(2);
expect(rows[0].columns[1].value).toEqual(remoteCluster2.name);
});
});
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/remote_clusters/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ export const PLUGIN = {
};

export const API_BASE_PATH = '/api/remote_clusters';

export const SNIFF_MODE = 'sniff';
export const PROXY_MODE = 'proxy';
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { deserializeCluster, serializeCluster } from './cluster_serialization';
describe('cluster_serialization', () => {
describe('deserializeCluster()', () => {
it('should throw an error for invalid arguments', () => {
// @ts-ignore
expect(() => deserializeCluster('foo', 'bar')).toThrowError();
});

Expand Down Expand Up @@ -60,6 +61,39 @@ describe('cluster_serialization', () => {
});
});

it('should deserialize a cluster that contains a deprecated proxy address', () => {
expect(
deserializeCluster(
'test_cluster',
{
seeds: ['localhost:9300'],
connected: true,
num_nodes_connected: 1,
max_connections_per_cluster: 3,
initial_connect_timeout: '30s',
skip_unavailable: false,
transport: {
ping_schedule: '-1',
compress: false,
},
},
'localhost:9300'
)
).toEqual({
name: 'test_cluster',
proxyAddress: 'localhost:9300',
mode: 'proxy',
hasDeprecatedProxySetting: true,
isConnected: true,
connectedNodesCount: 1,
maxConnectionsPerCluster: 3,
initialConnectTimeout: '30s',
skipUnavailable: false,
transportPingSchedule: '-1',
transportCompress: false,
});
});

it('should deserialize a cluster object with arbitrary missing properties', () => {
expect(
deserializeCluster('test_cluster', {
Expand All @@ -84,6 +118,7 @@ describe('cluster_serialization', () => {

describe('serializeCluster()', () => {
it('should throw an error for invalid arguments', () => {
// @ts-ignore
expect(() => serializeCluster('foo')).toThrowError();
});

Expand All @@ -105,8 +140,13 @@ describe('cluster_serialization', () => {
cluster: {
remote: {
test_cluster: {
mode: null,
node_connections: null,
proxy_address: null,
proxy_socket_connections: null,
seeds: ['localhost:9300'],
skip_unavailable: false,
server_name: null,
},
},
},
Expand All @@ -125,8 +165,13 @@ describe('cluster_serialization', () => {
cluster: {
remote: {
test_cluster: {
mode: null,
node_connections: null,
proxy_address: null,
proxy_socket_connections: null,
seeds: ['localhost:9300'],
skip_unavailable: null,
server_name: null,
},
},
},
Expand Down
Loading