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

[BACKPORT] Integrations from main #638

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
114 changes: 114 additions & 0 deletions .cypress/integration/9_integrations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

/// <reference types="cypress" />

import {
TEST_INTEGRATION_INSTANCE, TEST_SAMPLE_INSTANCE,
} from '../utils/constants';

let testInstanceSuffix = (Math.random() + 1).toString(36).substring(7);
let testInstance = `${TEST_INTEGRATION_INSTANCE}_${testInstanceSuffix}`;

const moveToIntegrationsHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/available`);
};

const moveToAvailableNginxIntegration = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/available/nginx`);
};

const moveToAddedIntegrations = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/installed`);
};

const createSamples = () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="try-it-button"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
}


describe('Basic sanity test for integrations plugin', () => {
it('Navigates to integrations plugin and expects the correct header', () => {
moveToIntegrationsHome();
cy.get('[data-test-subj="integrations-header"]').should('exist');
});

it('Navigates to integrations plugin and tests that clicking the nginx cards navigates to the nginx page', () => {
moveToIntegrationsHome();
cy.get('[data-test-subj="integration_card_nginx"]').click();
cy.url().should('include', '/available/nginx')
})

it('Navigates to nginx page and asserts the page to be as expected', () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="nginx-overview"]').should('exist')
cy.get('[data-test-subj="nginx-details"]').should('exist')
cy.get('[data-test-subj="nginx-screenshots"]').should('exist')
cy.get('[data-test-subj="nginx-assets"]').should('exist')
cy.get('[data-test-subj="fields"]').click();
cy.get('[data-test-subj="nginx-fields"]').should('exist')
})
});

describe('Tests the add nginx integration instance flow', () => {
it('Navigates to nginx page and triggers the adds the instance flow', () => {
createSamples();
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="add-integration-button"]').click();
cy.get('[data-test-subj="new-instance-name"]').should('have.value', 'nginx');
cy.get('[data-test-subj="createInstanceButton"]').should('be.disabled')
cy.get('[data-test-subj="addIntegrationFlyoutTitle"]').should('exist')
// validates the created sample index
cy.get('[data-test-subj="data-source-name"]').type('ss4o_logs-nginx-sample-sample');
cy.get('[data-test-subj="validateIndex"]').click()
cy.get('[data-test-subj="new-instance-name"]').type(testInstance.substring(5));
cy.get('[data-test-subj="createInstanceButton"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
})

it('Navigates to installed integrations page and verifies that nginx-test exists', () => {
moveToAddedIntegrations();
cy.contains(testInstance).should('exist');
cy.get(`[data-test-subj="${testInstance}IntegrationLink"]`).click();
})

it('Navigates to added integrations page and verifies that nginx-test exists and linked asset works as expected', () => {
moveToAddedIntegrations();
cy.contains(TEST_INTEGRATION_INSTANCE).should('exist');
cy.get(`[data-test-subj="${testInstance}IntegrationLink"]`).click();
cy.get(`[data-test-subj="IntegrationAssetLink"]`).click();
cy.url().should('include', '/dashboards#/')
})

it('Navigates to installed nginx-test instance page and deletes it', () => {
moveToAddedIntegrations();
cy.contains(testInstance).should('exist');
cy.get(`[data-test-subj="${testInstance}IntegrationLink"]`).click();
cy.get('[data-test-subj="deleteInstanceButton"]').click();

cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('be.disabled');

cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', {
delay: 50,
});
cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled');
cy.get('button[data-test-subj="popoverModal__deleteButton"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
})
});

describe('Tests the add nginx integration instance flow', () => {
it('Navigates to nginx page and triggers the try it flow', () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="try-it-button"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
moveToAddedIntegrations();
cy.contains(TEST_SAMPLE_INSTANCE).should('exist');
})
});


2 changes: 2 additions & 0 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => {

// notebooks
export const TEST_NOTEBOOK = 'Test Notebook';
export const TEST_INTEGRATION_INSTANCE = 'nginx-test';
export const TEST_SAMPLE_INSTANCE = 'nginx-sample';
export const SAMPLE_URL = 'https://github.com/opensearch-project/sql/tree/main/sql-jdbc';
export const NOTEBOOK_TEXT = 'Use Notebooks to interactively and collaboratively develop rich reports backed by live data. Common use cases for notebooks includes creating postmortem reports, designing run books, building live infrastructure reports, or even documentation.';
export const OPENSEARCH_URL = 'https://opensearch.org/docs/latest/observability-plugin/notebooks/';
Expand Down
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

const LICENSE_HEADER = `/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/`;

module.exports = {
root: true,
extends: [
Expand All @@ -15,6 +20,12 @@ module.exports = {
files: ['**/*.{js,ts,tsx}'],
rules: {
'no-console': 0,
'@osd/eslint/require-license-header': [
'error',
{
licenses: [LICENSE_HEADER],
},
],
},
},
],
Expand Down
30 changes: 30 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}

readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi

exit 0
fi
Comment on lines +1 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not part of main branch

3 changes: 2 additions & 1 deletion common/constants/custom_panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { v4 as uuidv4 } from 'uuid';
export const CUSTOM_PANELS_API_PREFIX = '/api/observability/operational_panels';
export const CUSTOM_PANELS_DOCUMENTATION_URL =
'https://opensearch.org/docs/latest/observability-plugin/operational-panels/';
export const CREATE_PANEL_MESSAGE = 'Enter a name to describe the purpose of this Observability Dashboard.';
export const CREATE_PANEL_MESSAGE =
'Enter a name to describe the purpose of this Observability Dashboard.';

export const CUSTOM_PANELS_SAVED_OBJECT_TYPE = 'observability-panel';

Expand Down
11 changes: 11 additions & 0 deletions common/constants/integrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const OPENSEARCH_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest/integrations/index';
export const ASSET_FILTER_OPTIONS = ['index-pattern', 'search', 'visualization', 'dashboard'];
// TODO get this list dynamically from the API
export const INTEGRATION_TEMPLATE_OPTIONS = ['nginx'];
// TODO get this list dynamically from the API
export const INTEGRATION_CATEOGRY_OPTIONS = ['communication', 'http', 'cloud', 'container', 'logs'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields shouldn’t be hard coded...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I know, we can fix it later.

6 changes: 6 additions & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const DSL_SEARCH = '/search';
export const DSL_CAT = '/cat.indices';
export const DSL_MAPPING = '/indices.getFieldMapping';
export const OBSERVABILITY_BASE = '/api/observability';
export const INTEGRATIONS_BASE = '/api/integrations';
export const EVENT_ANALYTICS = '/event_analytics';
export const SAVED_OBJECTS = '/saved_objects';
export const SAVED_QUERY = '/query';
Expand Down Expand Up @@ -51,6 +52,10 @@ export const observabilityPanelsID = 'observability-dashboards';
export const observabilityPanelsTitle = 'Dashboards';
export const observabilityPanelsPluginOrder = 5095;

export const observabilityIntegrationsID = 'integrations';
export const observabilityIntegrationsTitle = 'Integrations';
export const observabilityIntegrationsPluginOrder = 9020;

// Shared Constants
export const SQL_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest/search-plugins/sql/index/';
export const PPL_DOCUMENTATION_URL =
Expand All @@ -69,6 +74,7 @@ export const PPL_NEWLINE_REGEX = /[\n\r]+/g;

// Observability plugin URI
const BASE_OBSERVABILITY_URI = '/_plugins/_observability';
const BASE_INTEGRATIONS_URI = '/_plugins/_integrations'; // Used later in front-end for routing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not used as well. We can remove this

export const OPENSEARCH_PANELS_API = {
OBJECT: `${BASE_OBSERVABILITY_URI}/object`,
};
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,33 @@
"@reduxjs/toolkit": "^1.6.1",
"ag-grid-community": "^27.3.0",
"ag-grid-react": "^27.3.0",
"ajv": "^8.11.0",
"antlr4": "4.8.0",
"antlr4ts": "^0.5.0-alpha.4",
"mime": "^3.0.0",
"performance-now": "^2.1.0",
"plotly.js-dist": "^2.2.0",
"postinstall": "^0.7.4",
"react-graph-vis": "^1.0.5",
"react-paginate": "^8.1.3",
"react-plotly.js": "^2.5.1",
"redux-persist": "^6.0.0"
"redux-persist": "^6.0.0",
"sanitize-filename": "^1.6.3"
},
"devDependencies": {
"@cypress/skip-test": "^2.6.1",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/mime": "^3.0.1",
"@types/react-plotly.js": "^2.5.0",
"@types/react-test-renderer": "^16.9.1",
"@types/sanitize-filename": "^1.6.3",
"antlr4ts-cli": "^0.5.0-alpha.4",
"cypress": "^6.0.0",
"cypress-watch-and-reload": "^1.10.6",
"eslint": "^6.8.0",
"jest-dom": "^4.0.0",
"lint-staged": "^13.1.0",
"mock-fs": "^4.12.0",
"ts-jest": "^29.1.0"
},
"resolutions": {
Expand Down
2 changes: 2 additions & 0 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { observabilityID, observabilityTitle } from '../../common/constants/shar
import { store } from '../framework/redux/store';
import { AppPluginStartDependencies } from '../types';
import { Home as ApplicationAnalyticsHome } from './application_analytics/home';
import { Home as IntegrationsHome } from './integrations/home';
import { MetricsListener } from './common/metrics_listener';
import { Home as CustomPanelsHome } from './custom_panels/home';
import { EventAnalytics } from './event_analytics';
Expand Down Expand Up @@ -42,6 +43,7 @@ const pages = {
traces: TraceAnalyticsHome,
notebooks: NotebooksHome,
dashboards: CustomPanelsHome,
integrations: IntegrationsHome,
};

export const App = ({
Expand Down
Loading
Loading