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

feat: added support in env setup glue for fetching device details dynamically #188

Merged
merged 27 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91083ee
added support in env setup glue for fetching device details dynamically
anjalimukundan Aug 6, 2024
e4e2ae7
addressed review comments for error handling msg
anjalimukundan Aug 7, 2024
03660a0
added support in fcs to fetch device details dynamically
anjalimukundan Aug 9, 2024
00a8bd7
addressed review comments
anjalimukundan Aug 12, 2024
70ae3a5
updated deviceContentValidation
anjalimukundan Aug 12, 2024
ddb6a7f
added documentation for deviceContentValidation
anjalimukundan Aug 12, 2024
765a8f8
updated constant file
anjalimukundan Aug 13, 2024
034e7d5
updated constants file
anjalimukundan Aug 13, 2024
a574958
updated validations.js
anjalimukundan Aug 13, 2024
25bc6c9
resolved conflicts
anjalimukundan Aug 13, 2024
9aa65a2
removed deviceContentValidation check
anjalimukundan Aug 13, 2024
3dac48b
updated validations.js
anjalimukundan Aug 13, 2024
61fdbc3
removed fetch_device_details env
anjalimukundan Aug 14, 2024
1325275
updated validations.md file with eg:
anjalimukundan Aug 14, 2024
4d17a6d
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 19, 2024
64c28ea
updated the dynamic device details fetch flow for deviceContentValida…
anjalimukundan Aug 19, 2024
05aac2e
added comments for each if condition in validations.js
anjalimukundan Aug 19, 2024
6ee0c9b
resolved conflicts
anjalimukundan Aug 20, 2024
e8d42e7
addressed review comments for dynamic_details_fetch
anjalimukundan Aug 20, 2024
4db89d6
updated readme.doc
anjalimukundan Aug 21, 2024
cd359a1
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 21, 2024
4bff988
updated validations.md file with dynamic details fetch doc
anjalimukundan Aug 21, 2024
bf5710f
updated validations.md file
anjalimukundan Aug 21, 2024
c5585fb
updated readme file with fetchDeviceDetails override function
anjalimukundan Aug 21, 2024
6ccbf02
addressed review comments for documentation
anjalimukundan Aug 22, 2024
c9a7083
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 26, 2024
c0be880
added dynamicContentValidations.md
anjalimukundan Aug 26, 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
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,40 @@ HTTP call to the platform:<br/>
}
```

### fetchDeviceDetails:
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved

- Request:<br>
Making a call to fetch device details and the token required for dynamically fetching details .<br>

Format:
```
{
"method": "fcs.fetchDeviceDetails",
"params": <deviceId>
}

```
Examples:
```
{

"method": "fcs.fetchDeviceDetails",
"params": "354444327"
}
```
- Response:<br>
Receives the updated environment variable device_data with dynamic device details.
Example:

```
{
"DEVICEID": "354444327",
"DEVICE_TYPE": "ipstb",
"DEVICE_MODEL": "VALUE",
...
}
```

## Interaction Log service

See [Interaction_Logs,md](/Docs//Interaction_Logs.md)
Expand Down
10 changes: 2 additions & 8 deletions cypress/plugins/testDataProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,8 @@ function testDataHandler(requestType, dataIdentifier, fireboltObject) {
if (!deviceMac) {
logger.info('Falling back to default device data path');
}
let deviceData = fetchAndParseDataFromJson(deviceDataPath, data.type);
if (deviceData === CONSTANTS.NO_DATA) {
logger.info(
`Expected deviceData not found for ${data.type}. Returning ${data.type} as is.`
);
deviceData = data.type;
}
data.type = deviceData;
const deviceData = fetchDataFromFile(deviceDataPath);
envVariables[CONSTANTS.DEVICE_DATA] = deviceData;
break;

default:
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ module.exports = {
DEVICEMODULEFORMAT: 'deviceModelFormat',
DEVICE_AUDIO: 'device.audio',
DEVICE_CONTENT_VALIDATION: 'deviceContentValidation',
DEVICE_DATA: 'deviceData',
DEVICE_ENV: 'Device',
DEVICE_FIRMWARE: 'Device Firmware',
DEVICE_HDCP: 'device.hdcp',
DEVICE_HDR: 'device.hdr',
DEVICE_ID: 'device.id',
DEVICE_IP: 'deviceIp',
DEVICE_MAC: 'deviceMac',
DEVICE_MAC_UNAVAILABLE: 'Device MAC unavailable',
Expand All @@ -99,6 +101,7 @@ module.exports = {
DEVICE_PLATFORM: 'device.platform',
DEVICE_VIDEORESOLUTION: 'device.videoResolution',
DISCOVERY_LAUNCH: 'discovery.launch',
DYNAMIC_DEVICE_DETAILS_MODULES: ['Device'],
EMAIL: 'email',
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
ENV_PLATFORM_SDK_VERSION: 'platformSdkVersion',
ENV_PLATFORM: 'platform',
Expand Down Expand Up @@ -192,6 +195,7 @@ module.exports = {
CUSTOM: 'custom',
VALIDATION_FUNCTION: 'validationFunction',
NOT_SUPPORTED: 'NOT_SUPPORTED',
FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG: 'fetch_device_details_dynamically',
FIRST_PARTY_APPID: 'firstPartyAppId',
GENERATE_HTML_REPORT: true,
GETEVENTRESPONSE_ERROR_MSG: 'Received error: Requested listener not found',
Expand Down Expand Up @@ -362,6 +366,7 @@ module.exports = {
SETFIREBOLTINTERACTIONSHANDLER: 'fcs.setFireboltInteractionsHandler',
CREATE_MARKER: 'performance.createMarker',
UNLOADAPP: 'fcs.unloadApp',
FETCHDEVICEDETAILS: 'fcs.fetchDeviceDetails',
},
REQUEST_MAP_INTERACTIONS_SERVICE: 'Request map for firebolt interactions service : ',
RESPONSE: 'Response: ',
Expand Down
17 changes: 17 additions & 0 deletions cypress/support/step_definitions/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ Given('the environment has been set up for {string} tests', (test) => {
if (Cypress.env(CONSTANTS.TEST_TYPE).includes('rpc-Only')) {
Cypress.env(CONSTANTS.IS_RPC_ONLY, true);
}
// fetch device details dynamically
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) {
if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) {
cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then(
(response) => {
if (response) {
const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS;
const requestMap = {
method: method,
params: response,
};
cy.sendMessagetoPlatforms(requestMap);
}
}
);
}
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
}
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
26 changes: 26 additions & 0 deletions cypress/support/step_definitions/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@ Given(
: CONSTANTS.NULL_RESPONSE;
const expectingError = item.expectingError;
const isNullCase = item.isNullCase || false;
// check if the dynamic device details env is present
if (
Cypress.env(CONSTANTS.DEVICE_DATA) &&
Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0
) {
let type;
// if the validation object used for current validation contains the required data
if (contentObject && contentObject.data) {
for (let i = 0; i < contentObject.data.length; i++) {
if (
contentObject.data[i].validations &&
contentObject.data[i].validations[0] &&
contentObject.data[i].validations[0].type &&
contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION
) {
type = contentObject.data[i].validations[0].type;
// if the dynamic device details env contains the validation key
if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) {
contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[
type
];
}
}
}
}
}
anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved

// If the app ID is not passed from the feature, the default app ID will be retrieved.
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
appId = !appId
Expand Down
82 changes: 82 additions & 0 deletions cypress/support/step_definitions/validations.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,88 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/
]
}

# Dynamic Content Validation
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved

### Background:
For the fixture validations mentioned in [Supported Validations](./validations.md#supported-validations), deviceContentValidation is used when the validation is done based on device specific value.
For eg :

```
"DEVICE_ID": {
"data": [
{
"type": "fixture",
"validations": [
{
"mode": "deviceContentValidation",
"type": "DEVICEID",
"description": "Validation of the Device Id Format"
}
]
}
]
}

```

When the validation mode is "deviceContentValidation", the source of truth for the validation can be taken in two ways:
1. Static data
2. Dynamic data

Static data :
For static data, the source of truth is stored in a <deviceMac.json> file placed [here](../../fixtures/external/devices/) based on the deviceMac value being tested. When the test begins, these values are loaded into an object stored in an environment variable called deviceData. If deviceMac.json is not found in the specified path, the values are saved as they are, for example: DEVICEID: "DEVICEID".
anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved

Dynamic data :
For dynamic data, the source of truth is fetched from the configModule's override function called "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides).

anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved
### Usage :

To fetch dynamic data from configModule, set an environment variable fetch_device_details_dynamically as true in the [supportConfig.json](../../../supportConfig.json). If this environment variable is true, dynamic details will be fetched from configModule based on the platform and override the existing environment variable deviceData, which holds the static data from <deviceMac.json>.

If the dynamic device details fetching fails in configModule, the data will default to the static data. FCS expects the source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js).


### Implementation :

The configModule should have an override function "fetchDeviceDetails" as explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). This function should fetch the data and return it in the format specified below. If deviceId, deviceType, and distributor values need to be extracted, they should be saved as "DEVICEID", "DEVICE_TYPE", and "DEVICE_DISTRIBUTOR" keys, as these are the key names used in the validationObject. These values will then replace the values in <device-mac.json> stored in the environment variable "DEVICE_DATA" in FCS.

anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved
When the test starts, deviceId is passed from FCS to this override function for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js) as the only parameter, which is later used to extract device details. If the data contains multiple objects, the required device details are fetched by mapping them with the corresponding deviceId passed from FCS to configModule.
For example, if activeDevicedata is the dynamic device response, the data extraction will be as follows:

#### Format

```
if (activeDevicedata.id == deviceId) {
extractedData.DEVICEID = activeDevicedata.id;
extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType;
extractedData.DEVICE_DISTRIBUTOR = deviceData[0].data.partner;

}
Cypress.env(CONSTANTS.DEVICE_DATA, extractedData);
```

neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
### Example :
From FCS, the override function is invoked in the following format:
Format:
```
{
"method": "fcs.fetchDeviceDetails",
"params": <deviceId>
}

The response by overriding the static values in the environment will be as follows:
Example:

```
{
"DEVICEID": "354444327",
"DEVICE_TYPE": "ipstb",
"DEVICE_MODEL": "VALUE",
...
anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved
}
```


## Error Content Validation

### Background
Expand Down
Loading