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

Remote UI regression workflow : clean up the code #2614

Draft
wants to merge 68 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9a86e66
add Jenkinsfile
orkoresh4 Jul 2, 2024
5dd40ea
add Jenkinsfile
orkoresh4 Jul 2, 2024
f1781d1
add Jenkinsfile
orkoresh4 Jul 2, 2024
a78e95d
add Jenkinsfile
orkoresh4 Jul 2, 2024
f604f45
add Jenkinsfile
orkoresh4 Jul 2, 2024
1f20b29
add Jenkinsfile
orkoresh4 Jul 2, 2024
b82bd9d
add Jenkinsfile
orkoresh4 Jul 2, 2024
be628ce
add Jenkinsfile
orkoresh4 Jul 2, 2024
383c659
add Jenkinsfile
orkoresh4 Jul 2, 2024
ea9f9c6
add Jenkinsfile
orkoresh4 Jul 2, 2024
26301b0
add Jenkinsfile
orkoresh4 Jul 2, 2024
66b42da
add Jenkinsfile
orkoresh4 Jul 2, 2024
5b56669
add Jenkinsfile
orkoresh4 Jul 3, 2024
39bcaf8
add Jenkinsfile
orkoresh4 Jul 3, 2024
baa7cee
add Jenkinsfile
orkoresh4 Jul 3, 2024
6b686e4
add Jenkinsfile
orkoresh4 Jul 3, 2024
ab155e1
add Jenkinsfile
orkoresh4 Jul 3, 2024
9e01385
add Jenkinsfile
orkoresh4 Jul 3, 2024
4982f40
add Jenkinsfile
orkoresh4 Jul 3, 2024
cdd612c
add Jenkinsfile
orkoresh4 Jul 3, 2024
49d3b1e
add Jenkinsfile
orkoresh4 Jul 3, 2024
14da650
add Jenkinsfile
orkoresh4 Jul 3, 2024
70ebcc0
add Jenkinsfile
orkoresh4 Jul 3, 2024
29193c0
add Jenkinsfile
orkoresh4 Jul 3, 2024
7b6b427
add Jenkinsfile
orkoresh4 Jul 3, 2024
96d1a7b
add Jenkinsfile
orkoresh4 Jul 3, 2024
245e508
add scripts test for ci-cd flow
pinis-gini-apps Jul 4, 2024
1b56675
add scripts test for ci-cd flow (#2575)
pinis-gini-apps Jul 4, 2024
58029da
add Jenkinsfile
orkoresh4 Jul 4, 2024
62921d2
Merge remote-tracking branch 'origin/ui-ci-orkor' into ui-ci-orkor
orkoresh4 Jul 4, 2024
6a49557
add Jenkinsfile
orkoresh4 Jul 4, 2024
ba7e3ac
add Jenkinsfile
orkoresh4 Jul 4, 2024
9c57db5
add delay befor runing report script
pinis-gini-apps Jul 4, 2024
59c1b80
merge with upstream
pinis-gini-apps Jul 4, 2024
11eebde
undo changes in ui_ci.groovy
pinis-gini-apps Jul 4, 2024
94b151d
add delay before running report script (#2582)
pinis-gini-apps Jul 7, 2024
5acc492
add Jenkinsfile
orkoresh4 Jul 7, 2024
97cc069
add Jenkinsfile
orkoresh4 Jul 7, 2024
40bc34d
add Jenkinsfile
orkoresh4 Jul 7, 2024
4598a5d
add Jenkinsfile
orkoresh4 Jul 7, 2024
3e4ea9e
add Jenkinsfile
orkoresh4 Jul 7, 2024
803160d
add Jenkinsfile
orkoresh4 Jul 7, 2024
511282f
add Jenkinsfile
orkoresh4 Jul 7, 2024
6e3ed03
add Jenkinsfile
orkoresh4 Jul 7, 2024
805b6a7
remove console.log
pinis-gini-apps Jul 18, 2024
b17d471
change DRIVER_SLEEP to 8000, add git restore for httpClient.js
pinis-gini-apps Jul 18, 2024
49436a8
merge with upstream
pinis-gini-apps Jul 18, 2024
f82ee33
merge with development
pinis-gini-apps Jul 18, 2024
caee76f
Merge branch 'development' into ui-ci-orkor
pinis-gini-apps Jul 22, 2024
ff6f2cf
Remote UI regression workflow : clean up the code `ui-ci-orkor` (#2618)
pinis-gini-apps Jul 22, 2024
6c239d5
add add-comment-to-http-client script to 'Run Regression Tests' stage
pinis-gini-apps Jul 23, 2024
fabc69f
remove add-comment-to-http-client script to 'Run Regression Tests' st…
pinis-gini-apps Jul 23, 2024
acb997e
merge with upstream/ui-ci-orkor
pinis-gini-apps Jul 23, 2024
f4a7b4c
[ui-ci-orkor] fix jenkins build (#2621)
pinis-gini-apps Jul 23, 2024
dbc1fc2
added cleaning up
orkoresh4 Jul 28, 2024
a81ee9f
Merge remote-tracking branch 'upstream/ui-ci-orkor' into ui-ci-orkor
pinis-gini-apps Jul 29, 2024
7c02254
added cleaning up
orkoresh4 Jul 30, 2024
badbab5
Merge remote-tracking branch 'upstream/ui-ci-orkor' into ui-ci-orkor
pinis-gini-apps Aug 4, 2024
a3f6a9f
Align ui-ci-orkor with the development (#2640)
pinis-gini-apps Aug 4, 2024
ece880a
Merge remote-tracking branch 'upstream/ui-ci-orkor' into ui-ci-orkor
pinis-gini-apps Aug 11, 2024
e6b2bb4
merge with development
pinis-gini-apps Aug 11, 2024
5bd76f6
Remote UI regression workflow: update ui-ci-orkor with v1.7.0-rc37 (#…
EZheln Aug 13, 2024
45d8d01
merge with development, fix duplicated chooseMetricsDataCard variable…
pinis-gini-apps Aug 14, 2024
5c85e30
Fix [UI] duplication in DetailsMetrics component. (#2663)
pinis-gini-apps Aug 14, 2024
59e317b
Merge remote-tracking branch 'upstream/ui-ci-orkor' into ui-ci-orkor
pinis-gini-apps Aug 30, 2024
fba9f18
Merge branch 'development' into ui-ci-orkor
pinis-gini-apps Aug 30, 2024
4816fa1
merge with development
pinis-gini-apps Sep 9, 2024
3af1bc0
fix some duplicated line after the merge
pinis-gini-apps Sep 9, 2024
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@
"build-storybook": "build-storybook",
"mock-server": "node scripts/mockServer.js",
"mock-server:dev": "nodemon --watch tests/mockServer scripts/mockServer.js",
"add-comment-to-http-client": "node scripts/ci-cd-scripts/appendCommentToHttpClient.js",
"test:ci-cd-smoke-1": "DRIVER_SLEEP=8000 HEADLESS=true node scripts/ci-cd-scripts/tempSmoke1Test.js",
"test:ui": "node scripts/testui.js",
"report": "node tests/report.js",
"test:regression": "npm run test:ui && npm run report",
"test:regression": "DRIVER_SLEEP=8000 HEADLESS=true npm run test:ui && sleep 10 && echo 'Finished regression' && sleep 10 && npm run report",
"start:regression": "concurrently \"npm:mock-server\" \"npm:start\" \"npm:test:regression\"",
"ui-steps": "export BABEL_ENV=test; export NODE_ENV=test; npx -p @babel/core -p @babel/node babel-node --presets @babel/preset-env scripts/collectUITestsSteps.js",
"nli": "npm link iguazio.dashboard-react-controls",
Expand Down
34 changes: 34 additions & 0 deletions scripts/ci-cd-scripts/appendCommentToHttpClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright 2019 Iguazio Systems Ltd.

Licensed under the Apache License, Version 2.0 (the "License") with
an addition restriction as set forth herein. You may not use this
file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License 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.

In addition, you may not use the software for any purposes that are
illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
const fs = require('fs')
const path = require('path')

const sourceFilePath = path.join(__dirname, 'commentedHttpClient.js')
const targetFilePath = path.join(__dirname, '../../src/httpClient.js')

try {
const fileContent = fs.readFileSync(sourceFilePath, 'utf-8')
fs.writeFileSync(targetFilePath, fileContent)

console.log(`Successfully overwritten ${targetFilePath} with content from ${sourceFilePath}`)
} catch (err) {
console.error(`Error occurred: ${err.message}`)
process.exit(1)
}
194 changes: 194 additions & 0 deletions scripts/ci-cd-scripts/commentedHttpClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
Copyright 2019 Iguazio Systems Ltd.

Licensed under the Apache License, Version 2.0 (the "License") with
an addition restriction as set forth herein. You may not use this
file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License 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.

In addition, you may not use the software for any purposes that are
illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
import axios from 'axios'
import qs from 'qs'

// import { ConfirmDialog } from 'igz-controls/components'
import {
CANCEL_REQUEST_TIMEOUT,
LARGE_REQUEST_CANCELED
// PROJECTS_PAGE_PATH
} from './constants'
// import { openPopUp } from 'igz-controls/utils/common.util'
// import { mlrunUnhealthyErrors } from './components/ProjectsPage/projects.util'

const headers = {
'Cache-Control': 'no-cache'
}

// serialize a param with an array value as a repeated param, for example:
// { label: ['host', 'owner=admin'] } => 'label=host&label=owner%3Dadmin'
const paramsSerializer = params => qs.stringify(params, { arrayFormat: 'repeat' })

// const MAX_CONSECUTIVE_ERRORS_COUNT = 2
// let consecutiveErrorsCount = 0

export const mainBaseUrl = `${process.env.PUBLIC_URL}/api/v1`
export const mainBaseUrlV2 = `${process.env.PUBLIC_URL}/api/v2`

export const mainHttpClient = axios.create({
baseURL: mainBaseUrl,
headers,
paramsSerializer
})

export const mainHttpClientV2 = axios.create({
baseURL: mainBaseUrlV2,
headers,
paramsSerializer
})

export const functionTemplatesHttpClient = axios.create({
baseURL: `${process.env.PUBLIC_URL}/function-catalog`,
headers
})

export const nuclioHttpClient = axios.create({
baseURL: `${process.env.PUBLIC_URL}/nuclio/api`,
headers
})

export const iguazioHttpClient = axios.create({
baseURL: process.env.NODE_ENV === 'production' ? '/api' : '/iguazio/api',
headers
})

const getAbortSignal = (controller, abortCallback, timeoutMs) => {
let timeoutId = null
const newController = new AbortController()
const abortController = controller || newController

if (timeoutMs) {
timeoutId = setTimeout(() => abortController.abort(LARGE_REQUEST_CANCELED), timeoutMs)
}

abortController.signal.onabort = event => {
if (timeoutId) {
clearTimeout(timeoutId)
}

if (abortCallback) {
abortCallback(event)
}
}

return [abortController.signal, timeoutId]
}

let requestId = 1
let requestTimeouts = {}
let largeResponsePopUpIsOpen = false

const requestLargeDataOnFulfill = config => {
if (config?.ui?.setLargeRequestErrorMessage) {
const [signal, timeoutId] = getAbortSignal(
config.ui?.controller,
abortEvent => {
if (abortEvent.target.reason === LARGE_REQUEST_CANCELED) {
showLargeResponsePopUp(config.ui.setLargeRequestErrorMessage)
}
},
CANCEL_REQUEST_TIMEOUT
)

config.signal = signal

requestTimeouts[requestId] = timeoutId
config.ui.requestId = requestId
requestId++
}

return config
}
const requestLargeDataOnReject = error => {
return Promise.reject(error)
}
const responseFulfillInterceptor = response => {
// consecutiveErrorsCount = 0

if (response.config?.ui?.requestId) {
const isLargeResponse =
response.data?.total_size >= 0
? response.data.total_size > 10000
: Object.values(response.data)?.[0]?.length > 10000

clearTimeout(requestTimeouts[response.config.ui.requestId])
delete requestTimeouts[response.config.ui.requestId]

if (isLargeResponse) {
showLargeResponsePopUp(response.config.ui.setLargeRequestErrorMessage)

throw new Error(LARGE_REQUEST_CANCELED)
} else {
response.config.ui.setLargeRequestErrorMessage('')
}
}

return response
}
const responseRejectInterceptor = error => {
if (error.config?.ui?.requestId) {
clearTimeout(requestTimeouts[error.config.ui.requestId])
delete requestTimeouts[error.config.ui.requestId]
}

// if (error.config?.method === 'get') {
// if (
// mlrunUnhealthyErrors.includes(error.response?.status) &&
// consecutiveErrorsCount < MAX_CONSECUTIVE_ERRORS_COUNT
// ) {
// consecutiveErrorsCount++
//
// if (
// consecutiveErrorsCount === MAX_CONSECUTIVE_ERRORS_COUNT &&
// window.location.pathname !== `/${PROJECTS_PAGE_PATH}`
// ) {
// window.location.href = '/projects'
// }
// }
// }

return Promise.reject(error)
}

// Request interceptors
mainHttpClient.interceptors.request.use(requestLargeDataOnFulfill, requestLargeDataOnReject)
mainHttpClientV2.interceptors.request.use(requestLargeDataOnFulfill, requestLargeDataOnReject)

// Response interceptors
mainHttpClient.interceptors.response.use(responseFulfillInterceptor, responseRejectInterceptor)
mainHttpClientV2.interceptors.response.use(responseFulfillInterceptor, responseRejectInterceptor)

export const showLargeResponsePopUp = setLargeRequestErrorMessage => {
if (!largeResponsePopUpIsOpen) {
const errorMessage =
'The query result is too large to display. Add a filter (or narrow it) to retrieve fewer results.'

setLargeRequestErrorMessage(errorMessage)
largeResponsePopUpIsOpen = true

// openPopUp(ConfirmDialog, {
// message: errorMessage,
// closePopUp: () => {
// largeResponsePopUpIsOpen = false
// }
// })
}
}
28 changes: 28 additions & 0 deletions scripts/ci-cd-scripts/tempSmoke1Test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2019 Iguazio Systems Ltd.

Licensed under the Apache License, Version 2.0 (the "License") with
an addition restriction as set forth herein. You may not use this
file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License 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.

In addition, you may not use the software for any purposes that are
illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
const { execSync } = require('child_process')

const cucumberCommand =
"./node_modules/.bin/cucumber-js --require-module @babel/register --require-module @babel/polyfill -f json:tests/reports/cucumber_report.json -f html:tests/reports/cucumber_report_default.html tests -t '@smoke1'"
try {
execSync(cucumberCommand, { stdio: 'inherit' })
} catch (err) {
console.log(err.message)
}
51 changes: 28 additions & 23 deletions scripts/testui.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,53 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
'use strict';

const { report } = require('../tests/config');
const fs = require('fs');
const { report } = require('../tests/config')
const fs = require('fs')

// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'test';
process.env.NODE_ENV = 'test';
process.env.BABEL_ENV = 'test'
process.env.NODE_ENV = 'test'

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
throw err
})

// Ensure environment variables are read.
require('../config/env');
require('../config/env')

const execSync = require('child_process').execSync;
const argv = process.argv.slice(2);
const execSync = require('child_process').execSync
const argv = process.argv.slice(2)

// build cucumber executive command
const cucumberCommand = 'cucumber-js --require-module @babel/register --require-module @babel/polyfill ' +
'-f json:' + report + '.json -f html:' + report +'_default.html tests ' +
argv.join(' ');
const cucumberCommand =
'cucumber-js --require-module @babel/register --require-module @babel/polyfill ' +
'-f json:' +
report +
'.json -f html:' +
report +
'_default.html tests ' +
argv.join(' ') +
'-t @smoke'

// check and create report folder
const reportDir = report.split('/').slice(0, -1).join('/');
console.log(reportDir);
const reportDir = report.split('/').slice(0, -1).join('/')
console.log(reportDir)
if (!fs.existsSync(reportDir)) {
fs.mkdirSync(reportDir);
fs.mkdirSync(reportDir)
}

function runCrossPlatform() {
try {
execSync(cucumberCommand);
return true;
} catch (e) {
return false;
}
try {
execSync(cucumberCommand)
return true
} catch (e) {
return false
}
}

// cucumber
runCrossPlatform();
runCrossPlatform()
8 changes: 7 additions & 1 deletion tests/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/

const HEADLESS = process.env.HEADLESS === 'true' || false

/* eslint-disable-next-line no-console */
console.log(`DRIVER_SLEEP: ${HEADLESS}`)

module.exports = {
timeout: 60000,
browser: 'chrome',
headless: false,
headless: HEADLESS,
screen_size: { width: 1600, height: 900 },
report: 'tests/reports/cucumber_report',
test_url: 'localhost',
Expand Down
Loading
Loading