Skip to content

Commit 6a5b5e6

Browse files
committed
Deploy the troubleshooting plugin if it is not present.
1 parent 7801d20 commit 6a5b5e6

7 files changed

Lines changed: 87 additions & 63 deletions

File tree

web/cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from 'cypress';
2+
import registerCypressGrep from '@cypress/grep/src/plugin';
23
const fs = require('fs');
34
const path = require('path');
45
const report_dir = process.env.ARTIFACT_DIR || '/tmp';

web/cypress/cypress.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

web/cypress/e2e/acceptance.cy.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as dataTest from '../fixtures/data-test'
1+
import * as dt from '../fixtures/data-test'
22

33
describe('TroubleShoot Panel detection', { tags: ['@admin'] }, () => {
44
before( function() {
@@ -15,26 +15,25 @@ describe('TroubleShoot Panel detection', { tags: ['@admin'] }, () => {
1515

1616
it('basic elements validation ',{tags:['@smoke']}, () => {
1717
cy.clickNavLink(['Home', 'Projects']);
18-
cy.openTroubeshootPanel();
19-
//troubelShoot Panel title div
20-
//<div class="pf-v5-l-flex pf-m-gap-none tp-plugin__popover-title-bar">
21-
cy.get('div.tp-plugin__popover-title-bar')
18+
cy.openTroubleshootPanel();
19+
//troubleShoot Panel title div
20+
cy.get(dt.Classes.TroubleShootPanelTitleBar)
2221
.should('exist')
2322
.within(() => {
2423
cy.contains('h1', 'Troubleshooting');
2524
cy.get('h1').find('button').should('exist')
2625
cy.get('button[aria-label="Close"]').should('exist');
27-
cy.get('svg.tp-plugin__popover-close').should('exist');
26+
cy.get(dt.Classes.TroubleShootPanelCloseButton).should('exist');
2827
})
2928

3029
cy.contains('h1', 'Troubleshooting').find('button').first().click();
31-
cy.contains('.pf-v5-c-popover__title-text', 'Quickly diagnose and resolve issues by exploring correlated observability signals for resources.').should('exist');
30+
cy.contains(dt.Classes.TroubleShootPanelPopText, 'Quickly diagnose and resolve issues by exploring correlated observability signals for resources.').should('exist');
3231
cy.contains('h1', 'Troubleshooting').find('button').first().click();
3332

3433
//troubelShoot Panel query-container
3534
//<div pf-v5-c-expandable-section pf-m-expanded.pf-m-detached pf-m-indented tp-plugin__panel-query-container>
3635
//troubelShoot Panel query-container -- control div
37-
cy.get('div.tp-plugin__popover-content')
36+
cy.get(dt.Classes.TroubleShootPanelControlBar)
3837
.should('exist')
3938
.within(() => {
4039
cy.contains('button','Focus');
@@ -44,17 +43,17 @@ describe('TroubleShoot Panel detection', { tags: ['@admin'] }, () => {
4443
})
4544
//Click the force button
4645
cy.log("before Focus")
47-
cy.focusTroubeshootPanel();
46+
cy.focusTroubleshootPanel();
4847
//Click the Advance Button
49-
cy.clickTroubeshootPanelAdvance();
50-
cy.get('div.tp-plugin__panel-query-container')
48+
cy.clickTroubleshootPanelAdvance();
49+
cy.get(dt.Classes.TroubleShootPanelQueryContainer)
5150
.find('form')
5251
.within(() => {
5352
cy.contains('label', 'Time');
5453
cy.contains('button', 'Recent');
5554
cy.contains('button', 'Range');
5655
cy.contains('h6','Since');
57-
cy.get('div.pf-v5-c-number-input').should('exist');
56+
cy.get(dt.Classes.TroubleShootPanelNumerInput).should('exist');
5857
cy.contains('h6','Ago');
5958
cy.contains('button', 'days');
6059
cy.contains('button', 'Distance');
@@ -64,16 +63,16 @@ describe('TroubleShoot Panel detection', { tags: ['@admin'] }, () => {
6463
});
6564
//troubelShoot Panel query-container -- topology-container
6665
//<div class="pf-m-grow tp-plugin__panel-topology-container"><div class="pf-v6-l-stack"><div class="pf-v6-l-stack__item pf-m-fill pf-topology-container"><div class="pf-topology-content">
67-
cy.get('div.tp-plugin__panel-topology-container').should('exist');
66+
cy.get(dt.Classes.TroubleShootPanelTopologyContainer).should('exist');
6867
cy.get('div[data-test-id="topology"]').should('exist');
6968
cy.get('g[data-id="korrel8r_graph"]')
7069
.within(() => {
71-
cy.get('ellipse').should('exist');
72-
cy.get('g[class="pf-topology__node__label__badge"]').should('exist');
73-
cy.get('rect[class="pf-topology__node__action-icon__background"]').should('exist');
74-
cy.get('g[data-test-id="edge-handler"]').should('exist');
70+
cy.get('ellipse').should('exist'); // node element
71+
cy.get(dt.Classes.TroubleShootPanelNodeLabel).should('exist'); // text panel
72+
cy.get(dt.Classes.TroubleShootPanelNodeBackGround).should('exist'); //backgroup panel
73+
cy.get('g[data-test-id="edge-handler"]').should('exist'); // connection line
7574
})
76-
cy.get('span.pf-topology-control-bar')
75+
cy.get(dt.Classes.TroubleShootPanelGraphControlBar)
7776
.within(() => {
7877
cy.get('button[id="zoom-in"]').should('exist');
7978
cy.get('button[id="zoom-out"]').should('exist');

web/cypress/fixtures/data-test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,19 @@ export const Classes = {
215215
SilenceState: '.pf-v6-l-stack__item, .co-break-word',
216216
LogDetail: 'pf-v5-c-table__td lv-plugin__table__details',
217217
LogToolbar: 'pf-v5-c-toolbar__content-section',
218-
TroubleShootPanel: '.pf-v5-l-flex.pf-m-column.pf-m-gap-none.tp-plugin__popover',
218+
TroubleShootPanel: '.pf-m-column.pf-m-gap-none.tp-plugin__popover',
219+
AppLaunch: 'div.co-app-launcher',
220+
TroubleShootPanelTitleContainer: 'div.tp-plugin__popover',
221+
TroubleShootPanelQueryContainer: 'div.tp-plugin__panel-query-container',
222+
TroubleShootPanelTopologyContainer: 'div.tp-plugin__panel-topology-container',
223+
TroubleShootPanelTitleBar: 'div.tp-plugin__popover-title-bar',
224+
TroubleShootPanelControlBar: 'div.tp-plugin__popover-content',
225+
TroubleShootPanelPopText: 'pf-v5-c-popover__title-text',
226+
TroubleShootPanelCloseButton: 'svg.tp-plugin__popover-close',
227+
TroubleShootPanelNumerInput: 'div.pf-v5-c-number-input',
228+
TroubleShootPanelNodeLabel: 'g.pf-topology__node__label__badge',
229+
TroubleShootPanelNodeBackGroud: 'rect.pf-topology__node__action-icon__background',
230+
TroubleShootPanelGraphControlBar: 'span.pf-topology-control-bar',
219231
};
220232

221233
export const persesAriaLabels = {
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-namespace */
22
/// <reference types="cypress" />
33
import { guidedTour } from '../../views/tour';
4-
import * as dataTest from '../../fixtures/data-test';
4+
import * as dt from '../../fixtures/data-test';
55
import * as helperfuncs from '../views/utils';
66

77
declare global {
@@ -11,12 +11,16 @@ declare global {
1111
value?: string;
1212
}
1313
interface Chainable<Subject> {
14-
openTroubeshootPanel();
14+
openTroubleshootPanel();
15+
closeTroubleshootPanel();
16+
focusTroubleshootPanel();
17+
refreshTroubleshootPanel();
18+
getTroubleshootPanelQueryText();
1519
}
1620
}
1721
}
1822

19-
function retryOpenTroubeshootPanel(count = 5) {
23+
function retryOpenTroubleshootPanel(count = 5) {
2024
if (count === 0) {
2125
throw new Error('Popup did not appear after clicking the trigger')
2226
}
@@ -28,55 +32,52 @@ function retryOpenTroubeshootPanel(count = 5) {
2832
return
2933
} else {
3034
// Step 1: click trigger button
31-
cy.byLegacyTestID(dataTest.LegacyTestIDs.AppicationLauncher).click()
32-
cy.get('div.co-app-launcher').should('be.visible')
35+
cy.byLegacyTestID(dt.LegacyTestIDs.AppicationLauncher).click()
36+
cy.get(dt.Classes.AppLaunch).should('be.visible')
3337
cy.byButtonText('Signal Correlation').click()
3438
cy.wait(6000) // wait for 6 seconds
3539
// retry after small delay
36-
retryOpenTroubeshootPanel(count - 1)
40+
retryOpenTroubleshootPanel(count - 1)
3741
}
3842
})
3943
}
4044

41-
Cypress.Commands.add('openTroubeshootPanel', () => {
45+
Cypress.Commands.add('openTroubleshootPanel', () => {
4246
cy.window().its('document.readyState').should('eq', 'complete');
4347
// Retry until popup div appears.
44-
retryOpenTroubeshootPanel(5)
45-
cy.get('div.tp-plugin__panel-topology-container').should('be.visible');
48+
retryOpenTroubleshootPanel(5)
49+
cy.get(dt.Classes.TroubleShootPanelTopologyContainer).should('be.visible');
4650
})
4751

48-
Cypress.Commands.add('closeTroubeshootPanel', () => {
49-
cy.get('div.tp-plugin__popover')
50-
.find('svg.tp-plugin__popover-close')
51-
.click({force: true});
52+
Cypress.Commands.add('closeTroubleshootPanel', () => {
53+
cy.get(dt.Classes.TroubleShootPanelCloseButton).click({force: true});
5254
})
5355

54-
Cypress.Commands.add('focusTroubeshootPanel', () => {
55-
//cy.get('div. tp-plugin__panel-query-container').contains('button', 'Forcs').click();
56-
cy.get('div.tp-plugin__panel-query-container')
56+
Cypress.Commands.add('focusTroubleshootPanel', () => {
57+
cy.get(dt.Classes.TroubleShootPanelQueryContainer)
5758
.contains('button', 'Focus')
5859
.click({force: true});
5960
cy.get('body').trigger('mouseover');
6061
cy.get('body').click(0, 0);
61-
cy.get('div.tp-plugin__panel-topology-container').should('exist');
62+
cy.get(dt.Classes.TroubleShootPanelTopologyContainer).should('exist');
6263
})
6364

64-
Cypress.Commands.add('refreshTroubeshootPanel', () => {
65+
Cypress.Commands.add('refreshTroubleshootPanel', () => {
6566
//There’s no alternative way to locate this button
66-
cy.get('div.tp-plugin__panel-query-container')
67+
cy.get(dt.Classes.TroubleShootPanelQueryContainer)
6768
.find('button')
6869
.eq(2)
6970
.click({focus: true});
70-
cy.get('div.tp-plugin__panel-topology-container').should('be.visible')
71+
cy.get(dt.Classes.TroubleShootPanelTopologyContainer).should('be.visible')
7172
})
7273

73-
Cypress.Commands.add('clickTroubeshootPanelAdvance', () => {
74-
cy.get('div.tp-plugin__panel-query-container')
74+
Cypress.Commands.add('clickTroubleshootPanelAdvance', () => {
75+
cy.get(dt.Classes.TroubleShootPanelQueryContainer)
7576
.contains('button', 'Advanced')
7677
.click({focus: true});
7778
})
7879

79-
Cypress.Commands.add('getTroubeshootPanelQueryText', () => {
80+
Cypress.Commands.add('getTroubleshootPanelQueryText', () => {
8081
//Note: The advance tab need to be expaned before run this commands.
81-
return cy.get('div.tp-plugin__panel-query-container').find('textarea#query-input').invoke('val')
82+
return cy.get(dt.Classes.TroubleShootPanelQueryContainer).find('textarea#query-input').invoke('val')
8283
})

web/cypress/support/commands/utility-commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', (
116116

117117
Cypress.Commands.add('podImage', (pod: string, namespace: string) => {
118118
cy.log('Get pod image');
119+
cy.switchPerspective('Core platform', 'Administrator');
120+
cy.wait(5000);
119121
cy.clickNavLink(['Workloads', 'Pods']);
120122
cy.changeNamespace(namespace);
121123
cy.byTestID('page-heading').contains('Pods').should('be.visible');

web/scripts/run-e2e.sh

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,34 @@ function enable_idp_htpasswd()
107107
echo "Enable IDP uiauto-htpasswd-idp succesfully"
108108
}
109109

110+
function enable_troubleshoot_plugin()
111+
{
112+
if oc get pod -l app.kubernetes.io/name=observability-operator --field-selector=status.phase=Running -A -o name | grep -q .; then
113+
echo "#deploy troubleshooting-panel"
114+
cat <<EOF|oc apply -f -
115+
apiVersion: observability.openshift.io/v1alpha1
116+
kind: UIPlugin
117+
metadata:
118+
name: troubleshooting-panel
119+
spec:
120+
troubleshootingPanel:
121+
timeout: 10m
122+
type: TroubleshootingPanel
123+
EOF
124+
else
125+
echo "observability-operator is not installed or not in running status"
126+
exit 1
127+
fi
128+
}
129+
110130
########Main###################
111131
if [[ $KUBECONFIG == "" ]]; then
112132
echo "Exit, you must expose the Environment KUBECONFIG"
113133
exit 1
114134
fi
115135
116-
export CYPRESS_BASE_URL="https://$(oc get route console -n openshift-console -o jsonpath={.spec.host})"
117-
export CYPRESS_OPENSHIFT_VERSION=$(oc version -o json |jq -r '.openshiftVersion'|cut -f 1,2 -d.)
136+
enable_troubleshoot_plugin
118137
119-
data_mode=$(oc get uiplugin logging -o jsonpath='{.spec.logging.schema}')
120-
if [[ "$data_mode" == "" ]];then
121-
data_mode="viaq"
122-
fi
123138
if [[ "$CYPRESS_LOGIN_IDP" == "" || "$CYPRESS_LOGIN_USERS" == "" ]];then
124139
enable_idp_htpasswd
125140
export CYPRESS_LOGIN_IDP=uiauto-htpasswd-idp
@@ -130,11 +145,14 @@ if [[ $CYPRESS_LOGIN_USERS == "" ]];then
130145
exit 1
131146
fi
132147
133-
echo "export KUBECONFIG=${KUBECONFIG}"
134-
echo "export CYPRESS_BASE_URL=$CYPRESS_BASE_URL"
135-
echo "export CYPRESS_LOGIN_IDP=$CYPRESS_LOGIN_IDP"
136-
echo "export CYPRESS_LOGIN_USERS=$CYPRESS_LOGIN_USERS"
137-
echo "export CYPRESS_OPENSHIFT_VERSION=$CYPRESS_OPENSHIFT_VERSION"
148+
export CYPRESS_BASE_URL="https://$(oc get route console -n openshift-console -o jsonpath={.spec.host})"
149+
export CYPRESS_OPENSHIFT_VERSION=$(oc version -o json |jq -r '.openshiftVersion'|cut -f 1,2 -d.)
150+
151+
echo "KUBECONFIG=${KUBECONFIG}"
152+
echo "CYPRESS_BASE_URL=$CYPRESS_BASE_URL"
153+
echo "CYPRESS_LOGIN_IDP=$CYPRESS_LOGIN_IDP"
154+
echo "CYPRESS_LOGIN_USERS=<mask>"
155+
echo "CYPRESS_OPENSHIFT_VERSION=$CYPRESS_OPENSHIFT_VERSION"
138156
139157
echo "## Execute Cypress cases"
140158
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

0 commit comments

Comments
 (0)