-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Start/stop performance metrics collection for each test case without glue code #236
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,15 +89,6 @@ export default function (module) { | |
Cypress.env(CONSTANTS.MESSAGE_QUEUE, messageQueue); | ||
UTILS.parseExceptionList(); | ||
cy.getModuleReqIdJson(); | ||
if (UTILS.getEnvVariable(CONSTANTS.PERFORMANCE_METRICS) == true) { | ||
cy.startOrStopPerformanceService(CONSTANTS.INITIATED).then((response) => { | ||
if (response) { | ||
Cypress.env(CONSTANTS.IS_PERFORMANCE_METRICS_ENABLED, true); | ||
} | ||
}); | ||
} else { | ||
cy.log(CONSTANTS.PERFORMANCE_METRICS_NOT_ACTIVE); | ||
} | ||
|
||
// Merge fireboltCalls | ||
const v1FireboltCallsData = UTILS.getEnvVariable('fireboltCallsJson'); | ||
|
@@ -132,8 +123,36 @@ export default function (module) { | |
// beforeEach | ||
beforeEach(() => { | ||
UTILS.getEnvVariable(CONSTANTS.FB_INTERACTIONLOGS).clearLogs(); | ||
cy.getBeforeOperationObject(); | ||
UTILS.destroyGlobalObjects([CONSTANTS.LIFECYCLE_APP_OBJECT_LIST]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we adding a .then for lines 135 and 136. |
||
|
||
cy.getBeforeOperationObject().then(() => { | ||
const scenarioName = Cypress.env(CONSTANTS.SCENARIO_NAME); | ||
|
||
UTILS.destroyGlobalObjects([CONSTANTS.LIFECYCLE_APP_OBJECT_LIST]); | ||
|
||
if (UTILS.getEnvVariable(CONSTANTS.PERFORMANCE_METRICS) === true) { | ||
if (scenarioName) { | ||
const requestMap = { | ||
method: CONSTANTS.REQUEST_OVERRIDE_CALLS.CREATE_MARKER, | ||
params: scenarioName, | ||
}; | ||
fireLog.info(`Firebolt Call to 1st party App: ${JSON.stringify(requestMap)} `); | ||
cy.sendMessagetoPlatforms(requestMap).then((result) => { | ||
fireLog.isTrue( | ||
result.success, | ||
'Response for marker creation: ' + JSON.stringify(result) | ||
); | ||
}); | ||
|
||
cy.startOrStopPerformanceService(CONSTANTS.INITIATED).then((response) => { | ||
if (response) { | ||
Cypress.env(CONSTANTS.IS_PERFORMANCE_METRICS_ENABLED, true); | ||
} | ||
}); | ||
} | ||
} else { | ||
cy.log(CONSTANTS.PERFORMANCE_METRICS_NOT_ACTIVE); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 146 is nto 150 is not correct |
||
}); | ||
}); | ||
|
||
/** | ||
|
@@ -242,6 +261,17 @@ export default function (module) { | |
})(); | ||
}); | ||
|
||
// after each | ||
afterEach(() => { | ||
if (UTILS.getEnvVariable(CONSTANTS.IS_PERFORMANCE_METRICS_ENABLED, false) == true) { | ||
cy.startOrStopPerformanceService(CONSTANTS.STOPPED).then((response) => { | ||
if (response) { | ||
Cypress.env(CONSTANTS.IS_PERFORMANCE_METRICS_ENABLED, false); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not right, why are we stopping metrics collection in aftereach |
||
* @module main | ||
* @function sendMessagetoPlatforms | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright 2024 Comcast Cable Communications Management, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
const CONSTANTS = require('../constants/constants'); | ||
const UTILS = require('../cypress-support/src/utils'); | ||
|
||
Cypress.Commands.add('performanceValidation', (object) => { | ||
if (UTILS.getEnvVariable('performanceMetrics')) { | ||
const { type, process, percentile, threshold } = object.validations[0]; | ||
const requestMap = { | ||
method: CONSTANTS.REQUEST_OVERRIDE_CALLS.PERFORMANCE_THRESHOLD_VALIDATOR, | ||
params: { type, process, percentile, threshold }, | ||
}; | ||
|
||
cy.sendMessagetoPlatforms(requestMap).then((result) => { | ||
if (result.error) { | ||
cy.log('Failed to fetch and validate the performance metrics').then(() => { | ||
assert(false, result.error); | ||
}); | ||
} else { | ||
result.map((response) => { | ||
cy.log(response.message).then(() => { | ||
assert.equal(true, response?.success, response?.message); | ||
}); | ||
}); | ||
} | ||
}); | ||
} else { | ||
fireLog.info('performanceMetrics are disabled.'); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove this code ? This function is to start/stop metrics collection and that should reside in before operation