Skip to content

Commit ea6d4ea

Browse files
authored
Fixed cypress memory failures. (#1396)
* Troubleshooting cypress memory failures. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Troubleshooting cypress memory failures. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Troubleshooting cypress memory failures. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Rerun tests. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Troubleshooting cypress memory failures. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Troubleshooting cypress memory failures. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Removed duplicate actions dropdown. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Removed development logs. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Removed redundant environment config. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Enabled video capture. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Fixed test payloads. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Updated snapshots. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> * Fixed tab header styles. Signed-off-by: Thomas Hurney <hurneyt@amazon.com> --------- Signed-off-by: Thomas Hurney <hurneyt@amazon.com>
1 parent b9bb68f commit ea6d4ea

File tree

9 files changed

+98
-140
lines changed

9 files changed

+98
-140
lines changed

.cypress/fixtures/sample_cron_expression_query_level_monitor.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020
}
2121
],
2222
"ui_metadata": {
23-
"schedule": {}
23+
"schedule": {
24+
"cronExpression": "30 11 * * 1-5",
25+
"period": {
26+
"unit": "MINUTES",
27+
"interval": 1
28+
},
29+
"timezone": "US/Pacific",
30+
"daily": 0,
31+
"monthly": {
32+
"type": "day",
33+
"day": 1
34+
},
35+
"weekly": {
36+
"tue": false,
37+
"wed": false,
38+
"thur": false,
39+
"sat": false,
40+
"fri": false,
41+
"mon": false,
42+
"sun": false
43+
},
44+
"frequency": "cronExpression"
45+
}
2446
}
2547
}

.cypress/fixtures/sample_days_interval_query_level_monitor.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020
}
2121
],
2222
"ui_metadata": {
23-
"schedule": {}
23+
"schedule": {
24+
"cronExpression": "0 */1 * * *",
25+
"period": {
26+
"unit": "DAYS",
27+
"interval": 7
28+
},
29+
"timezone": null,
30+
"daily": 0,
31+
"monthly": {
32+
"type": "day",
33+
"day": 1
34+
},
35+
"weekly": {
36+
"tue": false,
37+
"wed": false,
38+
"thur": false,
39+
"sat": false,
40+
"fri": false,
41+
"mon": false,
42+
"sun": false
43+
},
44+
"frequency": "interval"
45+
}
2446
}
2547
}

.github/workflows/cypress-workflow.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,25 @@ on:
88
- "**"
99
env:
1010
OPENSEARCH_DASHBOARDS_VERSION: 'main'
11-
OPENSEARCH_VERSION: '3.0.0-SNAPSHOT'
1211
ALERTING_PLUGIN_BRANCH: 'main'
1312
jobs:
1413
tests:
15-
name: Run Cypress E2E tests
14+
name: Run ${{ matrix.spec }} Cypress tests
1615
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
# Running each spec separately due to cypress memory-related failures
20+
spec:
21+
- acknowledge_alerts_modal
22+
- alert
23+
- alerts_dashboard_flyout
24+
- bucket_level_monitor
25+
- cluster_metrics_monitor
26+
- composite_level_monitor
27+
- document_level_monitor
28+
- monitors_dashboard
29+
- query_level_monitor
1730
env:
1831
# prevents extra Cypress installation progress messages
1932
CI: 1
@@ -34,7 +47,7 @@ jobs:
3447
- name: Run Opensearch with plugin
3548
run: |
3649
cd alerting
37-
./gradlew :alerting:run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &
50+
./gradlew :alerting:run &
3851
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
3952
- name: Checkout OpenSearch Dashboards
4053
uses: actions/checkout@v2
@@ -64,27 +77,33 @@ jobs:
6477
run: |
6578
cd OpenSearch-Dashboards/plugins/alerting-dashboards-plugin
6679
yarn osd bootstrap --single-version=loose
80+
- name: Build plugin bundles
81+
run: |
82+
cd OpenSearch-Dashboards
83+
node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 4
6784
- name: Run OpenSearch Dashboards server
6885
run: |
6986
cd OpenSearch-Dashboards
70-
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
71-
sleep 300
72-
# timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5601/api/status)" != "200" ]]; do sleep 5; done'
87+
yarn start --no-base-path --no-watch --server.host="0.0.0.0" 2>&1 | tee /tmp/osd.log &
88+
timeout 300 bash -c 'while ! grep -qE "(bundles compiled successfully|all bundles cached)" /tmp/osd.log 2>/dev/null; do sleep 10; done'
89+
sleep 30
7390
- name: Run Cypress tests
7491
uses: cypress-io/github-action@v2
7592
with:
7693
working-directory: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin
77-
command: yarn run cypress run
94+
command: env CYPRESS_NO_COMMAND_LOG=1 yarn run cypress run --browser chrome --spec '.cypress/integration/${{ matrix.spec }}.spec.js'
95+
env:
96+
NODE_OPTIONS: '--max-old-space-size=6144'
7897

7998
# Screenshots are only captured on failure, will change this once we do visual regression tests
8099
- uses: actions/upload-artifact@v4
81100
if: failure()
82101
with:
83-
name: cypress-screenshots
84-
path: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin/cypress/screenshots
102+
name: cypress-screenshots-${{ matrix.spec }}
103+
path: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin/.cypress/screenshots
85104
# Test run video was always captured, so this action uses "always()" condition
86105
- uses: actions/upload-artifact@v4
87106
if: always()
88107
with:
89-
name: cypress-videos
90-
path: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin/cypress/videos
108+
name: cypress-videos-${{ matrix.spec }}
109+
path: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin/.cypress/videos

cypress.config.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const { defineConfig } = require('cypress')
1+
const { defineConfig } = require('cypress');
22

33
module.exports = defineConfig({
4-
defaultCommandTimeout: 10000,
4+
defaultCommandTimeout: 60000,
5+
viewportWidth: 2000,
6+
viewportHeight: 1320,
57
env: {
68
opensearch_url: 'localhost:9200',
79
opensearch_dashboards: 'localhost:5601',
@@ -11,16 +13,22 @@ module.exports = defineConfig({
1113
screenshotsFolder: '.cypress/screenshots',
1214
videosFolder: '.cypress/videos',
1315
e2e: {
14-
// We've imported your old cypress plugins here.
15-
// You may want to clean this up later by importing these.
1616
setupNodeEvents(on, config) {
17-
config.env.NODE_OPTIONS = '—max-old-space-size=8192';
17+
on('before:browser:launch', (browser, launchOptions) => {
18+
if (browser.name === 'chrome' || browser.name === 'chromium') {
19+
launchOptions.args.push('--disable-dev-shm-usage');
20+
launchOptions.args.push('--disable-gpu');
21+
launchOptions.args.push('--disable-extensions');
22+
launchOptions.args.push('--no-sandbox');
23+
}
24+
return launchOptions;
25+
});
1826
return require('./.cypress/plugins/index.js')(on, config);
1927
},
2028
specPattern: '.cypress/integration/*.spec.js',
2129
supportFile: '.cypress/support/index.js',
22-
// Performance optimizations
2330
numTestsKeptInMemory: 0,
2431
experimentalMemoryManagement: true,
32+
video: true,
2533
},
26-
})
34+
});

public/components/AlertInsight/AlertInsight.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ export const AlertInsight: React.FC<AlertInsightProps> = (props: AlertInsightPro
5858

5959
const contextProvider = async () => {
6060
// 1. get monitor definition
61-
console.log('[AlertInsight] fetching legacy monitor for alert', {
62-
alertId,
63-
monitorId: alert.monitor_id,
64-
dataSourceQuery,
65-
});
6661
const monitorResp = await httpClient.get(
6762
`../api/alerting/monitors/${alert.monitor_id}`,
6863
dataSourceQuery

public/pages/Dashboard/containers/DashboardClassic.js

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ export default class DashboardClassic extends Component {
5757
super(props);
5858

5959
const { location, perAlertView } = props;
60-
console.log('[DashboardClassic] constructor', {
61-
monitorIds: props.monitorIds,
62-
perAlertView,
63-
landingDataSourceId: props.landingDataSourceId,
64-
});
6560

6661
const { alertState, from, search, severityLevel, size, sortDirection, sortField } =
6762
getURLQueryParams(location);
@@ -111,7 +106,6 @@ export default class DashboardClassic extends Component {
111106
}
112107

113108
componentDidMount() {
114-
console.log('[DashboardClassic] componentDidMount');
115109
const { alertState, page, search, severityLevel, size, sortDirection, sortField, monitorIds } =
116110
this.state;
117111
this.getAlerts(
@@ -198,12 +192,6 @@ export default class DashboardClassic extends Component {
198192
monitorIds,
199193
monitorType: this.props.monitorType,
200194
};
201-
console.log('[DashboardClassic] getAlerts request', {
202-
params,
203-
resolvedDataSourceId,
204-
url: '../api/alerting/alerts',
205-
});
206-
207195
if (resolvedDataSourceId !== undefined) {
208196
params.dataSourceId = resolvedDataSourceId;
209197
}
@@ -212,10 +200,6 @@ export default class DashboardClassic extends Component {
212200
const { httpClient, history, notifications, perAlertView } = this.props;
213201
history.replace({ ...this.props.location, search: queryParamsString });
214202
httpClient.get('../api/alerting/alerts', { query: params }).then((resp) => {
215-
console.log('[DashboardClassic] getAlerts response', {
216-
ok: resp?.ok,
217-
totalAlerts: resp?.totalAlerts,
218-
});
219203
if (resp.ok) {
220204
const { alerts, totalAlerts } = resp;
221205
this.setState({ alerts, totalAlerts });
@@ -259,11 +243,6 @@ export default class DashboardClassic extends Component {
259243
this.dataSourceQuery = latestDataSourceQuery;
260244
}
261245
const query = (latestDataSourceQuery || this.dataSourceQuery)?.query;
262-
console.log('[DashboardClassic] getMonitors request', {
263-
monitorIds,
264-
query,
265-
});
266-
267246
if (dataSourceEnabled() && !_.get(query, 'dataSourceId')) {
268247
this.setState({ loadingMonitors: false });
269248
return;
@@ -285,16 +264,11 @@ export default class DashboardClassic extends Component {
285264

286265
if (response.ok) {
287266
monitors = _.get(response, 'resp.hits.hits', []);
288-
console.log('[DashboardClassic] getMonitors response', {
289-
count: monitors.length,
290-
});
291267
} else {
292268
console.log('error getting monitors:', response);
293-
console.log('[DashboardClassic] getMonitors response error', response);
294269
}
295270
} catch (err) {
296271
console.error(err);
297-
console.log('[DashboardClassic] getMonitors exception', err);
298272
}
299273
this.setState({ loadingMonitors: false, monitors });
300274
}
@@ -640,47 +614,13 @@ export default class DashboardClassic extends Component {
640614
/>
641615
)}
642616
<ContentPanel
643-
title={perAlertView ? 'Alerts' : undefined}
617+
title={perAlertView ? 'Alerts' : useUpdatedUx ? undefined : 'Alerts by triggers'}
644618
titleSize={'s'}
645619
bodyStyles={{ padding: 'initial' }}
646620
actions={useUpdatedUx ? undefined : inlineActions}
647621
panelOptions={{ hideTitleBorder: useUpdatedUx }}
648622
panelStyles={{ padding: useUpdatedUx && totalAlerts < 1 ? '16px 16px 0px' : '16px' }}
649623
>
650-
{!perAlertView && (
651-
<>
652-
<div
653-
style={{
654-
padding: useUpdatedUx ? '16px 16px 0px 16px' : '0px 0px 16px',
655-
}}
656-
>
657-
<EuiFlexGroup
658-
alignItems="center"
659-
justifyContent="spaceBetween"
660-
gutterSize="s"
661-
responsive={false}
662-
>
663-
<EuiFlexItem grow={false}>
664-
<EuiTitle size="l">
665-
<h1>Alerts by triggers</h1>
666-
</EuiTitle>
667-
</EuiFlexItem>
668-
{showInlineActions && (
669-
<EuiFlexItem grow={false}>
670-
<EuiFlexGroup gutterSize="s" responsive={false}>
671-
{inlineActions.map((action, idx) => (
672-
<EuiFlexItem key={idx} grow={false}>
673-
{action}
674-
</EuiFlexItem>
675-
))}
676-
</EuiFlexGroup>
677-
</EuiFlexItem>
678-
)}
679-
</EuiFlexGroup>
680-
</div>
681-
{useUpdatedUx && <EuiSpacer size="m" />}
682-
</>
683-
)}
684624
<DashboardControls
685625
activePage={page}
686626
pageCount={Math.ceil(totalItems / size) || 1}
@@ -693,14 +633,8 @@ export default class DashboardClassic extends Component {
693633
onPageChange={this.onPageClick}
694634
isAlertsFlyout={isAlertsFlyout}
695635
monitorType={monitorType}
696-
alertActions={undefined}
697-
panelStyles={{
698-
padding: perAlertView
699-
? '8px 0px 16px'
700-
: useUpdatedUx
701-
? '0px 16px 16px'
702-
: '0px 0px 16px',
703-
}}
636+
alertActions={useUpdatedUx ? inlineActions : undefined}
637+
panelStyles={{ padding: perAlertView ? '8px 0px 16px' : '0px 0px 16px' }}
704638
/>
705639

706640
<EuiBasicTable

public/pages/MonitorDetails/containers/MonitorDetailsV1.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ export default class MonitorDetailsV1 extends Component {
103103
if (this.context?.dataSourceId) {
104104
setDataSource({ dataSourceId: this.context.dataSourceId });
105105
}
106-
console.log('[MonitorDetailsV1] componentDidMount', {
107-
monitorId: this.props.match.params.monitorId,
108-
viewMode: this.props.viewMode,
109-
locationSearch: this.props.location?.search,
110-
});
111106
this.getMonitor(this.props.match.params.monitorId);
112107
const dataSourceQuery = getDataSourceQueryObj();
113108
this.getLocalClusterName(dataSourceQuery);
@@ -186,7 +181,6 @@ export default class MonitorDetailsV1 extends Component {
186181
const isWorkflow = this.isWorkflow();
187182
const url = `../api/alerting/${isWorkflow ? 'workflows' : 'monitors'}/${id}`;
188183
const dataSourceQuery = getDataSourceQueryObj();
189-
console.log('[MonitorDetailsV1] getMonitor:start', { id, isWorkflow, url, dataSourceQuery });
190184
const response = httpClient.get(url, dataSourceQuery);
191185
response
192186
.then((resp) => {
@@ -199,11 +193,6 @@ export default class MonitorDetailsV1 extends Component {
199193
ifSeqNo,
200194
ifPrimaryTerm,
201195
} = resp;
202-
console.log('[MonitorDetailsV1] getMonitor response', {
203-
ok,
204-
hasResp: Boolean(monitor),
205-
version: monitorVersion,
206-
});
207196
if (ok) {
208197
if (isWorkflow) {
209198
this.updateDelegateMonitors(monitor);
@@ -229,7 +218,6 @@ export default class MonitorDetailsV1 extends Component {
229218
})
230219
.catch((err) => {
231220
console.log('err', err);
232-
console.log('[MonitorDetailsV1] getMonitor error', err);
233221
});
234222
};
235223

0 commit comments

Comments
 (0)