Skip to content

Commit

Permalink
Merge branch 'main' into test-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mengweieric committed Apr 6, 2022
2 parents 9c9ecf7 + b3c27d8 commit f836083
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 1,354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ describe('Creating application', () => {
cy.get('.aa-List').find('.aa-Item').should('have.length', 1);
cy.focused().type('{enter}');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain', 'source ');
cy.focused().type('{enter}');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain', 'source = ');
cy.focused().type('opensearch');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').click();
cy.get('.aa-Item').contains('opensearch_dashboards_sample_data_flights').click();
cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain', 'source = opensearch_dashboards_sample_data_flights ');
cy.focused().type('{downArrow}');
cy.focused().type('{enter}');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain', 'source = opensearch_dashboards_sample_data_flights, ');
cy.focused().type('opensearch');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').click();
cy.get('.aa-Item').contains('opensearch_dashboards_sample_data_logs').click();
cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain', 'source = opensearch_dashboards_sample_data_flights,opensearch_dashboards_sample_data_logs ');
});

it('Creates an application and redirects to application', () => {
Expand Down Expand Up @@ -212,6 +225,14 @@ describe('Viewing application', () => {
cy.get('[data-test-subj="superDatePickerShowDatesButton"]').should('contain', 'Last 24 months');
});

it('Shows latency variance in dashboards table', () => {
moveToApplication(nameOne);
changeTimeTo24('months');
cy.get('.euiBasicTable').first().within(($table) => {
cy.get('.plot-container').should('have.length.at.least', 1);
})
});

it('Saves time range for each application', () => {
moveToCreatePage();
cy.get('[data-test-subj="nameFormRow"]').type(nameTwo);
Expand Down Expand Up @@ -323,6 +344,7 @@ describe('Viewing application', () => {
cy.get('[data-test-subj="searchAutocompleteTextArea"]').click();
cy.get('.aa-List').find('.aa-Item').should('have.length', 11);
cy.get('[data-test-subj="searchAutocompleteTextArea"]').type('x');
cy.focused().clear();
cy.get('[data-test-subj="searchAutocompleteTextArea"]').clear().wait(delay * 2).type(spanQueryOnePartOne);
cy.get('[data-test-subj="searchAutocompleteTextArea"]').wait(delay * 2).type(spanQueryOnePartTwo);
cy.get('[data-test-subj="searchAutocompleteTextArea"]').wait(delay * 2).type(spanQueryOnePartThree);
Expand Down Expand Up @@ -356,6 +378,12 @@ describe('Viewing application', () => {
cy.get('[aria-label="Select #54B399 as the color"]').click();
cy.wait(delay);
cy.get('[data-test-subj="nameFieldText"]').click().type('Available');
cy.get('option').contains('≥').should('exist');
cy.get('option').contains('≤').should('exist');
cy.get('option').contains('>').should('exist');
cy.get('option').contains('<').should('exist');
cy.get('option').contains('=').should('exist');
cy.get('option').contains('≠').should('exist');
cy.get('[data-test-subj="expressionSelect"]').select('>');
cy.get('[data-test-subj="valueFieldNumber"]').clear().type('0.5');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
Expand Down
34 changes: 22 additions & 12 deletions dashboards-observability/common/constants/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const PIPE_AFTER_MATCH = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s|')+")

// Regex for dedup command
export const FIELD_IN_FIELD_LOOP = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*,\s*([^\s,]*)$/;
export const PIPE_COMMA_AFTER_FIELD = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s+$/;
export const COMMA_PIPE_AFTER_FIELD = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s+$/;
export const PIPE_AFTER_KEEP_EMPTY = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s*keepempty=true\s+$/;
export const PIPE_AFTER_CONSECUTIVE = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s*consecutive=true\s+$/;

Expand All @@ -99,18 +99,18 @@ export const PIPE_MATH_AFTER_EXPRESSIONS = /^\s*eval\s+(\S+\s*=\s*\S+(\s*(\+|\-|
// Regex for fields command
export const PLUS_MINUS_FIELD_AFTER_FIELDS = /^\s*fields\s+\S*$/;
export const FIELD_AFTER_PLUS_MINUS = /^\s*fields\s+(\+|\-)\s*\S*$/;
export const PIPE_COMMA_AFTER_FIELDS = /^\s*fields\s+((\+|\-)\s+)?\S+\s*(,\s*\S+\s*)*\s+$/;
export const COMMA_PIPE_AFTER_FIELDS = /^\s*fields\s+((\+|\-)\s+)?\S+\s*(,\s*\S+\s*)*\s+$/;
export const FIELD_IN_FIELDS_LOOP = /^\s*fields\s+((\+|\-)\s+)?\S+\s*(,\s*\S+\s*)*,\s*\S*$/;

// Regex for rare/top command
export const PIPE_COMMA_BY_AFTER_FIELD = /^\s*(rare|top(\s+\d+)?)\s+\S+\s*(,\s*\S+\s*)*\s+\S*$/;
export const COMMA_PIPE_BY_AFTER_FIELD = /^\s*(rare|top(\s+\d+)?)\s+\S+\s*(,\s*\S+\s*)*\s+\S*$/;
export const RARE_TOP_FIELD_LOOP = /^\s*(rare|top(\s+\d+)?)\s+\S+\s*(,\s*\S+\s*)*,\s*\S*$/;
export const FIELD_AFTER_BY = /^\s*(rare|top(\s+\d+)?)\s+\S+\s*(,\s*\S+\s*)*\s+by\s+\S*$/;
export const PIPE_AFTER_GROUP_BY = /^\s*(rare|top(\s+\d+)?)\s+\S+\s*(,\s*\S+\s*)*\s+by\s+\S+\s+$/;

// Regex for rename command
export const AS_AFTER_FIELD = /^\s*rename\s+((,\s*)?\S+\s+as\s+\S+\s*)*\s*(,\s*)?\S+\s+\S*$/;
export const PIPE_COMMA_AFTER_RENAME_FIELD = /^\s*rename\s+((,\s*)?\S+\s+as\s+\S+\s*)+$/;
export const COMMA_PIPE_AFTER_RENAME_FIELD = /^\s*rename\s+((,\s*)?\S+\s+as\s+\S+\s*)+$/;
export const FIELD_AFTER_COMMA = /^\s*rename\s+((,\s*)?\S+\s+as\s+\S+\s*)+\s*,\s+\S*$/;

// Regex for head command
Expand All @@ -119,7 +119,7 @@ export const PIPE_AFTER_HEAD = /^\s*head\s+\d+\s+/;
// Regex for sort command
export const PLUS_MINUS_FIELD_AFTER_SORT = /^\s*sort(\s+\d+)?\s+\S*$/;
export const FIELD_AFTER_PLUS_MINUS_SORT = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?\s*\S+\s*)*\s+(\+|\-)\s*\S*$/;
export const PIPE_COMMA_AFTER_SORT_FIELD = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?\s*\S+\s*)*\s+\S+\s+$/;
export const COMMA_PIPE_AFTER_SORT_FIELD = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?\s*\S+\s*)*\s+\S+\s+$/;
export const PLUS_MINUS_FIELD_IN_FIELDS_LOOP = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?\s*\S+\s*)*,\s+\S*$/;

// Regex for stats command
Expand All @@ -129,14 +129,20 @@ export const FIELD_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp
export const CLOSE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s|')+")|(\d+\.?\d*)|\w+)\s+$/;
export const PIPE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s|')*")|(\d*\.?\d*)|\w*)\s*\)\s*$/;
export const CLOSE_AFTER_FIELD = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))*(,\s*)?(sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s+$/;
export const PIPE_COMMA_BY_AFTER_AGGREGATION = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+\S*$/;
export const COMMA_PIPE_BY_AFTER_AGGREGATION = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+\S*$/;
export const PIPE_AFTER_STATS_GROUP_BY = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+\S+\s+$/;
export const AGGREGATION_FOR_STATS= /^\s*stats\s+(((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+,\s*)?\S*$/;

// Regex for parse command
export const STRING_FIELD_AFTER_PARSE = /^\s*parse\s+\S*$/;
export const PIPE_AFTER_PARSE = /^\s*parse\s+\S+\s+$/;

// Regex for source command
export const EQUAL_AFTER_SOURCE = /^\s*source\s+$/;
export const INDEX_AFTER_EQUAL = /^\s*source\s+=\s+[^\\\/\?\"\<\>\|\s\,\#]*$/;
export const PIPE_COMMA_AFTER_INDEX = /^\s*source\s+=\s+[^\\\/\?\"\<\>\|\s\,\#]+(,[^\\\/\?\"\<\>\|\s\,\#]+)*\s+$/;
export const MORE_INDEX_AFTER_COMMA = /^\s*source\s+=\s+[^\\\/\?\"\<\>\|\s\,\#]+(,[^\\\/\?\"\<\>\|\s\,\#]+)*,\s*[^\\\/\?\"\<\>\|\s\,\#]*\s*$/;

export const regexForSuggestion = [
EMPTY_REGEX,
FIELD_AFTER_COMMAND,
Expand All @@ -149,7 +155,7 @@ export const regexForSuggestion = [
CLOSE_AFTER_DATA,
PIPE_AFTER_MATCH,
FIELD_IN_FIELD_LOOP,
PIPE_COMMA_AFTER_FIELD,
COMMA_PIPE_AFTER_FIELD,
PIPE_AFTER_KEEP_EMPTY,
PIPE_AFTER_CONSECUTIVE,
EQUAL_AFTER_EVAL_FIELD,
Expand All @@ -158,31 +164,35 @@ export const regexForSuggestion = [
PIPE_MATH_AFTER_EXPRESSIONS,
PLUS_MINUS_FIELD_AFTER_FIELDS,
FIELD_AFTER_PLUS_MINUS,
PIPE_COMMA_AFTER_FIELDS,
COMMA_PIPE_AFTER_FIELDS,
FIELD_IN_FIELDS_LOOP,
PIPE_COMMA_BY_AFTER_FIELD,
COMMA_PIPE_BY_AFTER_FIELD,
RARE_TOP_FIELD_LOOP,
FIELD_AFTER_BY,
PIPE_AFTER_GROUP_BY,
PIPE_COMMA_AFTER_RENAME_FIELD,
COMMA_PIPE_AFTER_RENAME_FIELD,
FIELD_AFTER_COMMA,
AS_AFTER_FIELD,
PIPE_AFTER_HEAD,
PLUS_MINUS_FIELD_AFTER_SORT,
FIELD_AFTER_PLUS_MINUS_SORT,
PLUS_MINUS_FIELD_IN_FIELDS_LOOP,
PIPE_COMMA_AFTER_SORT_FIELD,
COMMA_PIPE_AFTER_SORT_FIELD,
FIELD_SPAN_AFTER_GROUP_BY,
NUM_FIELD_AFTER_AGGREGATION,
FIELD_AFTER_SPAN,
CLOSE_AFTER_SPAN,
PIPE_AFTER_SPAN,
CLOSE_AFTER_FIELD,
PIPE_COMMA_BY_AFTER_AGGREGATION,
COMMA_PIPE_BY_AFTER_AGGREGATION,
PIPE_AFTER_STATS_GROUP_BY,
AGGREGATION_FOR_STATS,
STRING_FIELD_AFTER_PARSE,
PIPE_AFTER_PARSE,
EQUAL_AFTER_SOURCE,
INDEX_AFTER_EQUAL,
PIPE_COMMA_AFTER_INDEX,
MORE_INDEX_AFTER_COMMA,
];

export const regexForIndex = [
Expand Down
2 changes: 0 additions & 2 deletions dashboards-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"@types/react-test-renderer": "^16.9.1",
"@cypress/skip-test": "^2.6.1",
"cypress": "^5.0.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
"jest-dom": "^4.0.0",
"performance-now": "^2.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,13 +1120,6 @@ Object {
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"
tabindex="0"
/>
<div
aria-hidden="true"
data-aria-hidden="true"
data-focus-guard="true"
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"
tabindex="1"
/>
<div
data-focus-lock-disabled="false"
>
Expand Down Expand Up @@ -17220,13 +17213,6 @@ Object {
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"
tabindex="0"
/>
<div
aria-hidden="true"
data-aria-hidden="true"
data-focus-guard="true"
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"
tabindex="1"
/>
<div
data-focus-lock-disabled="false"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EuiHorizontalRule,
EuiInMemoryTable,
EuiLink,
EuiLoadingSpinner,
EuiOverlayMask,
EuiPage,
EuiPageBody,
Expand Down Expand Up @@ -203,7 +204,9 @@ export function AppTable(props: AppTableProps) {
name: 'Current Availability',
sortable: true,
render: (value, record) => {
if (value.name) {
if (value.name === 'loading') {
return <EuiLoadingSpinner />;
} else if (value.name) {
return <EuiBadge color={value.color || 'default'}>{value.name}</EuiBadge>;
} else {
return <EuiText>Undefined</EuiText>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import DSLService from 'public/services/requests/dsl';
import React, { useState } from 'react';
import {
getFullSuggestions,
parseGetSuggestions,
onItemSelect,
} from '../../../../../public/components/common/search/autocomplete_logic';
import { uiSettingsService } from '../../../../../common/utils';
Expand Down Expand Up @@ -138,7 +138,7 @@ export const LogConfig = (props: LogConfigProps) => {
handleQueryChange={handleQueryChange}
handleQuerySearch={() => {}}
dslService={dslService}
getSuggestions={getFullSuggestions}
getSuggestions={parseGetSuggestions}
onItemSelect={onItemSelect}
isDisabled={editMode}
tabId={'application-analytics-tab'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export const calculateAvailability = async (
const panelId = application.panelId;
if (!panelId) return availability;
// Fetches saved visualizations associated to application's panel
// Order visualizations by most recently created
const savedVisualizationsIds = (await fetchPanelsVizIdList(http, panelId)).reverse();
if (!savedVisualizationsIds) return availability;
const visWithAvailability = [];
Expand Down Expand Up @@ -241,39 +242,71 @@ export const calculateAvailability = async (
hasAvailability = true;
// If there is an availiabilityVisId selected we only want to compute availability based on that
if (availabilityVisId ? availabilityVisId === visualizationId : true) {
if (!availabilityFound && threshold.expression) {
const expression = threshold.expression;
switch (expression) {
case '>':
if (currValue > parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '<':
if (currValue < parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '=':
if (currValue === parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
if (threshold.value !== null) {
if (!availabilityFound && threshold.expression) {
const expression = threshold.expression;
switch (expression) {
case '≥':
if (currValue >= parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '≤':
if (currValue <= parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '>':
if (currValue > parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '<':
if (currValue < parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '=':
if (currValue === parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
case '≠':
if (currValue !== parseFloat(threshold.value)) {
availability = {
name: threshold.name,
color: threshold.color,
mainVisId: visualizationId,
};
availabilityFound = true;
}
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,25 @@ export const Home = (props: HomeProps) => {
return http
.get(`${APP_ANALYTICS_API_PREFIX}/`)
.then(async (res) => {
// Want to calculate availability going down the table
for (let i = 0; i < res.data.length; i++) {
res.data[i].availability = { name: 'loading', color: '', mainVisId: '' };
}
setApplicationList(res.data);
for (let i = res.data.length - 1; i > -1; i--) {
res.data[i].availability = await calculateAvailability(
http,
pplService,
res.data[i],
res.data[i].availability.mainVisId,
() => {}
);
// Need to set state with new object to trigger re-render
setApplicationList([
...res.data.filter((app: ApplicationListType) => app.id !== res.data[i].id),
res.data[i],
]);
}
setApplicationList(res.data);
})
.catch((err) => {
setToast('Error occurred while fetching applications', 'danger');
Expand Down
Loading

0 comments on commit f836083

Please sign in to comment.