Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Migrate entire plugin to new platform #328

Merged
merged 43 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
91df3a5
Move server-side plugin lifecycle to server/index.ts
ohltyler Nov 9, 2020
4bcafd8
Migrate base Router and RouteHandler in server/router.ts
ohltyler Nov 9, 2020
2528777
Update all service calls away from legacy
ohltyler Nov 9, 2020
2acb955
Remove syntax error
ohltyler Nov 9, 2020
b18aa39
Add ability for custom logging on server-side
ohltyler Nov 10, 2020
fd6d9b9
Create new entry point for client side plugin
ohltyler Nov 10, 2020
e637362
Move to new platform HTTP client
ohltyler Nov 10, 2020
0b517dd
Expose core services to all plugin components
ohltyler Nov 10, 2020
157abbc
Remove legacy config files and consume core for CreateDetector page
ohltyler Nov 10, 2020
cf7f904
Consume core services for main UI components
ohltyler Nov 11, 2020
b76b834
Remove remaining legacy ui/ imports
ohltyler Nov 11, 2020
d1ac1bb
Remove unnecessary query-string and required plugins list
ohltyler Nov 11, 2020
bb741c5
Add CoreServicesContext to render fn to render plugin
ohltyler Nov 11, 2020
19766b8
Migrate client-side client to HttpSetup
ohltyler Nov 12, 2020
b7f6dcf
Fix for ad redux
ohltyler Nov 12, 2020
386f281
Clean up server apis
ohltyler Nov 12, 2020
d36a19f
Create a client and register all api calls with the client
ohltyler Nov 12, 2020
3d782b7
Fix server response and parsing for AD apis
ohltyler Nov 12, 2020
3a08994
Fix server response and parsing for remaining apis
ohltyler Nov 12, 2020
b4f2afe
Fix leftover kibana response parsing logic
ohltyler Nov 12, 2020
0892e89
Fix node apis for most detector crud operations
ohltyler Nov 12, 2020
67ef921
Minor cleanup
ohltyler Nov 13, 2020
37eb516
Fix formatting for most files
ohltyler Nov 13, 2020
086ae03
Fix remaining node apis
ohltyler Nov 13, 2020
0e2d00d
Fix more response parsing on client side
ohltyler Nov 13, 2020
7dfce67
Fix index related client-side api calls
ohltyler Nov 13, 2020
ab6fa42
Fix 3 more missed node api parsing issues
ohltyler Nov 14, 2020
ccd2e26
Override headers when setting up server-side plugin
ohltyler Nov 16, 2020
a6bf8a8
Pass core to all FeatureBreakdown components
ohltyler Nov 16, 2020
4ccd813
Add custom styling back
ohltyler Nov 16, 2020
a46c1a7
Fix dark mode for anomaly results charts
ohltyler Nov 16, 2020
2e2cf82
Inherit core services via context instead of props
ohltyler Nov 17, 2020
57b81c5
Define Features component by function instead of class
ohltyler Nov 17, 2020
b76bcf8
Mock core services for create detector page tests
ohltyler Nov 17, 2020
6a985bf
Add core services to more component tests and fix reducer tests
ohltyler Nov 17, 2020
ab45aae
Fix all remaining mocks that include data field
ohltyler Nov 17, 2020
5fc21bf
Finish wrapping all necessary component tests in context provider
ohltyler Nov 17, 2020
860f954
Update yarn test:e2e script to cd to base dir before starting server
ohltyler Nov 18, 2020
d224a21
Upgrade cypress to listen to fetch requests
ohltyler Nov 18, 2020
608e8db
Upgrade cypress github actions to fix set-env deprecation
ohltyler Nov 18, 2020
f68ce94
Remove unused yarn script
ohltyler Nov 19, 2020
65ee487
Remove unnecessary stringifying
ohltyler Nov 19, 2020
1a11083
Remove optional plugins in manifest file
ohltyler Nov 20, 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
38 changes: 14 additions & 24 deletions .cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ Cypress.Commands.add('mockGetDetectorOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'GET',
buildAdApiUrl(DETECTORS + '*'),
`fixture:${fixtureFileName}`
).as('getDetectors');
cy.route2(buildAdApiUrl(DETECTORS + '*'), `fixture:${fixtureFileName}`).as(
'getDetectors'
);

funcMockedOn();

Expand All @@ -66,11 +64,9 @@ Cypress.Commands.add('mockCreateDetectorOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'POST',
buildAdApiUrl(DETECTORS + '*'),
`fixture:${fixtureFileName}`
).as('createDetector');
cy.route2(buildAdApiUrl(DETECTORS + '*'), `fixture:${fixtureFileName}`).as(
'createDetector'
);

funcMockedOn();

Expand All @@ -82,11 +78,9 @@ Cypress.Commands.add('mockSearchIndexOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'GET',
buildAdApiUrl(INDICES_PATH + '*'),
`fixture:${fixtureFileName}`
).as('getIndices');
cy.route2(buildAdApiUrl(INDICES_PATH + '*'), `fixture:${fixtureFileName}`).as(
'getIndices'
);

funcMockedOn();

Expand All @@ -98,7 +92,7 @@ Cypress.Commands.add('mockSearchOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route('POST', buildAdApiUrl(SEARCH_PATH), `fixture:${fixtureFileName}`).as(
cy.route2(buildAdApiUrl(SEARCH_PATH), `fixture:${fixtureFileName}`).as(
'searchES'
);

Expand All @@ -112,8 +106,7 @@ Cypress.Commands.add('mockGetIndexMappingsOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'GET',
cy.route2(
buildAdApiUrl(MAPPINGS_PATH + '*'),
`fixture:${fixtureFileName}`
).as('getMappings');
Expand All @@ -129,8 +122,7 @@ Cypress.Commands.add('mockStartDetectorOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'POST',
cy.route2(
buildAdApiUrl([DETECTORS, detectorId, START_PATH].join(SLASH)),
`fixture:${fixtureFileName}`
).as('startDetector');
Expand All @@ -146,8 +138,7 @@ Cypress.Commands.add('mockStopDetectorOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'POST',
cy.route2(
buildAdApiUrl([DETECTORS, detectorId, STOP_PATH].join(SLASH)),
`fixture:${fixtureFileName}`
).as('stopDetector');
Expand All @@ -163,8 +154,7 @@ Cypress.Commands.add('mockDeleteDetectorOnAction', function (
funcMockedOn: VoidFunction
) {
cy.server();
cy.route(
'DELETE',
cy.route2(
buildAdApiUrl([DETECTORS, detectorId].join(SLASH)),
`fixture:${fixtureFileName}`
).as('deleteDetector');
Expand Down
4 changes: 3 additions & 1 deletion .cypress/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const buildAdApiUrl = (apiPath: string): string => {
};

export const buildServerApiUrl = (appPath: string, apiPath: string): string => {
return [API_URL_PREFIX, appPath, apiPath].join(SLASH);
return [Cypress.config('baseUrl'), API_URL_PREFIX, appPath, apiPath].join(
SLASH
);
};

export const buildAdAppUrl = (pagePath: string): string => {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
sleep 180

- name: Run e2e tests
uses: cypress-io/github-action@v1
uses: cypress-io/github-action@v2.5.0
with:
working-directory: kibana/plugins/anomaly-detection-kibana-plugin
command: yarn cy:run --env SECURITY_ENABLED=true
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
cd kibana/plugins/anomaly-detection-kibana-plugin
yarn kbn bootstrap
- name: Run e2e tests
uses: cypress-io/github-action@v1
uses: cypress-io/github-action@v2.5.0
with:
working-directory: kibana/plugins/anomaly-detection-kibana-plugin
command: yarn test:e2e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ offline-module-cache/v2/*
offline-module-cache/v1/*
.cypress/screenshots
.cypress/videos
target
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"requestTimeout": 90000,
"responseTimeout": 90000,
"defaultCommandTimeout": 90000,
"experimentalNetworkStubbing": true,
"env": {
"SECURITY_ENABLED": false
}
Expand Down
79 changes: 0 additions & 79 deletions index.js

This file was deleted.

10 changes: 10 additions & 0 deletions kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "opendistroAnomalyDetectionKibana",
"version": "1.11.0.0",
"kibanaVersion": "7.9.1",
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
"configPath": ["opendistro_anomaly_detection_kibana"],
"requiredPlugins": ["navigation"],
"optionalPlugins": [],
"server": true,
"ui": true
}
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
"test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js",
"build": "plugin-helpers build",
"release": "./tasks/release.sh",
"start-cy-server": "yarn start --no-base-path --oss",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:run-with-security": "cypress run --env SECURITY_ENABLED=true",
"test:e2e": "CHOKIDAR_USEPOLLING=1 CYPRESS_responseTimeout=180000 WAIT_ON_TIMEOUT=900000 start-server-and-test 'yarn start-cy-server' http-get://localhost:5601/app/opendistro-anomaly-detection-kibana 'echo sleeping to wait for server to get ready && sleep 180 && yarn cy:run'"
"test:e2e": "CHOKIDAR_USEPOLLING=1 CYPRESS_responseTimeout=180000 WAIT_ON_TIMEOUT=900000 start-server-and-test 'cd ../../ && yarn start --no-base-path --oss && cd plugins/anomaly-detection-kibana-plugin' http-get://localhost:5601/app/opendistro-anomaly-detection-kibana 'echo sleeping to wait for server to get ready && sleep 180 && yarn cy:run'"
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
},
"lint-staged": {
"*.{ts,tsx,js,jsx,json,css,md}": [
Expand All @@ -42,7 +41,6 @@
"@testing-library/jest-dom": "^4.0.0",
"@testing-library/react": "^8.0.6",
"@testing-library/user-event": "^4.2.3",
"@types/angular": "^1.6.55",
"@types/chance": "^1.0.6",
"@types/elasticsearch": "^5.0.34",
"@types/hapi": "^18.0.2",
Expand All @@ -60,7 +58,7 @@
"babel-jest": "^24.8.0",
"babel-polyfill": "^6.26.0",
"chance": "^1.1.0",
"cypress": "^4.11.0",
"cypress": "^5.6.0",
"eslint": "^5.6.0",
"eslint-plugin-babel": "^5.2.0",
"eslint-plugin-import": "^2.14.0",
Expand All @@ -85,7 +83,6 @@
"formik": "^1.5.8",
"lodash": "^4.17.19",
"plotly.js": "^1.55.2",
"query-string": "^6.8.2",
"react-plotly.js": "^2.4.0",
"react-redux": "^7.1.0",
"react-vis": "^1.11.7",
Expand Down
51 changes: 51 additions & 0 deletions public/anomaly_detection_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

import { CoreStart, AppMountParameters } from '../../../src/core/public';
import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter as Router, Route } from 'react-router-dom';
import { Main } from './pages/main';
import { Provider } from 'react-redux';
import configureStore from './redux/configureStore';
import { CoreServicesContext } from './components/CoreServices/CoreServices';

export function renderApp(coreStart: CoreStart, params: AppMountParameters) {
const http = coreStart.http;
const store = configureStore(http);

// Load Chart's dark mode CSS (if applicable)
const isDarkMode = coreStart.uiSettings.get('theme:darkMode') || false;
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
if (isDarkMode) {
require('@elastic/charts/dist/theme_only_dark.css');
} else {
require('@elastic/charts/dist/theme_only_light.css');
}
ReactDOM.render(
<Provider store={store}>
<Router>
<Route
render={(props) => (
<CoreServicesContext.Provider value={coreStart}>
<Main {...props} />
</CoreServicesContext.Provider>
)}
/>
</Router>
</Provider>,
params.element
);
return () => ReactDOM.unmountComponentAtNode(params.element);
}
64 changes: 0 additions & 64 deletions public/app.js

This file was deleted.

Loading