Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 10 additions & 23 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Coverage

on:
pull_request:
branches: [ main, develop]
branches: [ main]

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
Expand Down Expand Up @@ -31,32 +31,18 @@ jobs:
run: |
docker run -d --name native-platform -v ${{ github.workspace }}:/mnt/L1_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest

- name: Run unit tests with coverage flags enabled
run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh --enable-cov"
- name: Run unit tests with coverage flags enabled and Caculate the code coverage summary
run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh --enable-cov && lcov --list coverage.info | grep 'Lines\|Total' > /tmp/coverage_summary.txt"

- name: Caculate the code coverage summary
run: |
lcov --list coverage.info | grep "Lines\|Total" > /tmp/Gtest_Report/coverage_summary.txt

- name: Copy the code coverage to runner
run: |
docker cp native-platform:/tmp/Gtest_Report/ /tmp/Gtest_Report/
- name: Copy coverage summary to runner
run: docker cp native-platform:/tmp/coverage_summary.txt /tmp/

upload-test-results:
name: Upload L1 coverage reports
needs: execute-unit-code-coverage-report-on-release
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest
volumes:
- /tmp/Gtest_Report:/tmp/Gtest_Report
steps:
- name: Update the coverage report to Pull request using actions
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const lcov_result = fs.readFileSync('/tmp/Gtest_Report/coverage_summary.txt', 'utf8');
const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8');

github.issues.createComment({
issue_number: context.issue.number,
Expand All @@ -71,12 +57,13 @@ jobs:
});

- name: Generate the html report
run: |
genhtml coverage.info --output-directory /tmp/coverage_report
run: docker exec -i native-platform /bin/bash -c " cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && genhtml coverage.info --output-directory /tmp/coverage_report"

- name: Copy html report to runner
run: docker cp native-platform:/tmp/coverage_report /tmp/

- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /tmp/coverage_report

16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [1.6.5](https://github.com/rdkcentral/telemetry/compare/1.6.4...1.6.5)

- ISSUE-76 : Fix race condition during aggressive reloads [`#189`](https://github.com/rdkcentral/telemetry/pull/189)
- Add "REPORT_TYPE":"CACHED" to cache reports [`#154`](https://github.com/rdkcentral/telemetry/pull/154)
- RDKB-62050 : Telemetry report upload failed while using Red Recovery [`#191`](https://github.com/rdkcentral/telemetry/pull/191)
- Resolve code coverage hang issue in develop [`#185`](https://github.com/rdkcentral/telemetry/pull/185)

#### [1.6.4](https://github.com/rdkcentral/telemetry/compare/1.6.3...1.6.4)

- RDKB-61931: Removing Openssl Engine setup/override logic in Telemetry [`#186`](https://github.com/rdkcentral/telemetry/pull/186)
> 6 October 2025

- Removing Openssl Engine setup/override logic in Telemetry [`#186`](https://github.com/rdkcentral/telemetry/pull/186)
- RDK-59038: Improve L1 test coverage [`#176`](https://github.com/rdkcentral/telemetry/pull/176)
- Deploy fossid_integration_stateless_diffscan_target_repo action [`#182`](https://github.com/rdkcentral/telemetry/pull/182)
- ISSUE-76: Ensure Signal Handler in not preempted [`#181`](https://github.com/rdkcentral/telemetry/pull/181)
- Deploy cla action [`#123`](https://github.com/rdkcentral/telemetry/pull/123)
- RDKB-61783: Update curlinterface.c [`3ef7367`](https://github.com/rdkcentral/telemetry/commit/3ef73672d79760e15ce39485d76749398b31dc91)
- RDKB-61783: Update xconfclient.c [`3a53047`](https://github.com/rdkcentral/telemetry/commit/3a530471dc93df0ef94b3f15bc7f696271fb2e03)
- Changelog updates for release 1.6.4 - Correct libcurl SSL api usage [`73fb221`](https://github.com/rdkcentral/telemetry/commit/73fb22121d8554880a684ff079e1d2dec2b251fb)
- Update curlinterface.c [`3ef7367`](https://github.com/rdkcentral/telemetry/commit/3ef73672d79760e15ce39485d76749398b31dc91)
- Update xconfclient.c [`3a53047`](https://github.com/rdkcentral/telemetry/commit/3a530471dc93df0ef94b3f15bc7f696271fb2e03)

#### [1.6.3](https://github.com/rdkcentral/telemetry/compare/1.6.2...1.6.3)

Expand Down
2 changes: 2 additions & 0 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ static void* CollectAndReport(void* data)
Vector_RemoveItem(profile->cachedReportList, (void*) thirdCachedReport, NULL);
free(thirdCachedReport);
}
// Before caching the report, add "REPORT_TYPE": "CACHED"
tagReportAsCached(&jsonReport);
Vector_PushBack(profile->cachedReportList, jsonReport);

T2Info("Report Cached, No. of reportes cached = %lu\n", (unsigned long )Vector_Size(profile->cachedReportList));
Expand Down
32 changes: 19 additions & 13 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/bulkdata/profilexconf.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/bulkdata/profilexconf.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 1020 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/bulkdata/profilexconf.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -220,6 +220,11 @@
do
{
T2Info("%s while Loop -- START \n", __FUNCTION__);
if(singleProfile == NULL)
{
T2Error("%s is called with empty profile, profile reload might be in-progress, skip the request\n", __FUNCTION__);
goto reportXconfThreadEnd;
}
profile = singleProfile;
Vector *profileParamVals = NULL;
Vector *grepResultList = NULL;
Expand Down Expand Up @@ -349,6 +354,8 @@
Vector_RemoveItem(profile->cachedReportList, (void*) thirdCachedReport, NULL);
free(thirdCachedReport);
}
// Before caching the report, add "REPORT_TYPE": "CACHED"
// tagReportAsCached(&jsonReport);
Vector_PushBack(profile->cachedReportList, strdup(jsonReport));
profile->reportInProgress = false;
/* CID 187010: Dereference before null check */
Expand Down Expand Up @@ -419,6 +426,8 @@
Vector_RemoveItem(profile->cachedReportList, (void*) thirdCachedReport, NULL);
free(thirdCachedReport);
}
// Before caching the report, add "REPORT_TYPE": "CACHED"
tagReportAsCached(&jsonReport);
Vector_PushBack(profile->cachedReportList, strdup(jsonReport));

T2Info("Report Cached, No. of reportes cached = %lu\n", (unsigned long)Vector_Size(profile->cachedReportList));
Expand Down Expand Up @@ -494,7 +503,6 @@
//pthread_mutex_unlock(&plMutex);
reportXconfThreadEnd :
T2Info("%s while Loop -- END \n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
pthread_cond_wait(&reuseThread, &plMutex);
}
while(initialized);
Expand Down Expand Up @@ -592,7 +600,6 @@
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
pthread_join(singleProfile->reportThread, NULL);
reportThreadExits = false;
singleProfile->reportInProgress = false ;
T2Info("Final report is completed, releasing profile memory\n");
}
Expand Down Expand Up @@ -727,21 +734,13 @@

if(singleProfile->reportInProgress)
{
T2Info("Waiting for CollectAndReport to be complete : %s\n", singleProfile->name);
pthread_mutex_lock(&plMutex);
initialized = false;
T2Info("Sending signal to reuse Thread in CollectAndReportXconf\n");
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
pthread_join(singleProfile->reportThread, NULL);
T2Info("reportThread exits and initialising the profile list\n");
reportThreadExits = false;
initialized = true;
singleProfile->reportInProgress = false ;
T2Info("Waiting for CollectAndReportXconf to be complete : %s\n", singleProfile->name);
}

pthread_mutex_lock(&plMutex);

profile->reportThread = singleProfile->reportThread;

size_t count = Vector_Size(singleProfile->cachedReportList);
// Copy any cached message present in previous single profile to new profile
if(isNameEqual)
Expand Down Expand Up @@ -1009,9 +1008,14 @@

T2ERROR ret = T2ERROR_FAILURE;

pthread_mutex_lock(&plMutex);

if(!singleProfile)
{
T2Error("Xconf profile is not set.\n");

pthread_mutex_unlock(&plMutex);

return ret;
}

Expand Down Expand Up @@ -1039,6 +1043,8 @@
T2Info("No report generation in progress. No further action required for abort.\n");
}

pthread_mutex_unlock(&plMutex);

return ret;

}
Expand Down
10 changes: 8 additions & 2 deletions source/protocol/http/curlinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ static T2ERROR setPayload(CURL *curl, const char* payload, childResponse *childC
return T2ERROR_SUCCESS;
}
#ifdef LIBRDKCERTSEL_BUILD
#if defined(ENABLE_RED_RECOVERY_SUPPORT)
bool isStateRedEnabled(void)
{
return access("/tmp/stateRedEnabled", F_OK) == 0;
}
#endif
void curlCertSelectorFree()
{
rdkcertselector_free(&curlCertSelector);
Expand All @@ -269,7 +271,10 @@ void curlCertSelectorFree()
}
static void curlCertSelectorInit()
{
bool state_red_enable = isStateRedEnabled();
bool state_red_enable = false;
#if defined(ENABLE_RED_RECOVERY_SUPPORT)
state_red_enable = isStateRedEnabled();
#endif
if (state_red_enable && curlRcvryCertSelector == NULL )
{
curlRcvryCertSelector = rdkcertselector_new( NULL, NULL, "RCVRY" );
Expand Down Expand Up @@ -338,9 +343,10 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid)
}
#ifdef LIBRDKCERTSEL_BUILD
curlCertSelectorInit();
#if defined(ENABLE_RED_RECOVERY_SUPPORT)
state_red_enable = isStateRedEnabled();
T2Info("%s: state_red_enable: %d\n", __func__, state_red_enable );

#endif
if (state_red_enable)
{
thisCertSel = curlRcvryCertSelector;
Expand Down
58 changes: 58 additions & 0 deletions source/reportgen/reportgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,3 +876,61 @@ char *prepareHttpUrl(T2HTTP *http)

return httpUrl;
}

void tagReportAsCached(char **jsonReport)
{
if (!jsonReport)
{
T2Error("jsonReport is NULL\n");
return;
}

cJSON *jsonReportObj = cJSON_Parse(*jsonReport);
if (!jsonReportObj)
{
T2Error("Failed to parse JSON report\n");
return;
}

cJSON *reportTypeEntry = cJSON_CreateObject();
if (!reportTypeEntry)
{
T2Error("Failed to create REPORT_TYPE object\n");
destroyJSONReport(jsonReportObj);
return;
}
cJSON_AddStringToObject(reportTypeEntry, "REPORT_TYPE", "CACHED");
cJSON *searchResult = cJSON_GetObjectItemCaseSensitive(jsonReportObj, "searchResult");
if (searchResult && cJSON_IsArray(searchResult))
{
T2Info("Inserting REPORT_TYPE: CACHED at index 1 of searchResult array\n");
cJSON_InsertItemInArray(searchResult, 1, reportTypeEntry);
}
else
{
cJSON *reportArray = cJSON_GetObjectItemCaseSensitive(jsonReportObj, "Report");
if (reportArray && cJSON_IsArray(reportArray))
{
T2Info("Inserting REPORT_TYPE: CACHED at beginning of Report array\n");
cJSON_InsertItemInArray(reportArray, 0, reportTypeEntry);
}
else
{
T2Error("Neither 'searchResult' nor 'Report' arrays found in the JSON\n");
destroyJSONReport(reportTypeEntry);
destroyJSONReport(jsonReportObj);
return;
}
}

char *updatedJsonReport = cJSON_PrintUnformatted(jsonReportObj);
if (updatedJsonReport)
{
free(*jsonReport); // Freeing the old report only after the new one is generated
*jsonReport = updatedJsonReport;
}

destroyJSONReport(jsonReportObj);
}


2 changes: 2 additions & 0 deletions source/reportgen/reportgen.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/reportgen/reportgen.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/reportgen/reportgen.h' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 81 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/reportgen/reportgen.h)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -79,4 +79,6 @@

char *prepareHttpUrl(T2HTTP *http);

void tagReportAsCached(char **jsonReport);

#endif /* _REPORTGEN_H_ */
5 changes: 2 additions & 3 deletions source/test/bulkdata/datamodelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ TEST_F(datamodelTestFixture, datamodel_processProfile_RP)
"\"HTTP\":{\"URL\":\"https://stbrtl.r53.xcal.tv/\",\"Compression\":\"None\",\"Method\":\"POST\","
"\"RequestURIParameter\":[{\"Name\":\"reportName\",\"Reference\":\"Profile.Name\"}]},"
"\"JSONEncoding\":{\"ReportFormat\":\"NameValuePair\",\"ReportTimestamp\":\"None\"}}}]}";

EXPECT_CALL(*g_datamodelMock, ReportProfiles_ProcessReportProfilesBlob(_, _))
.Times(1);
EXPECT_EQ(T2ERROR_SUCCESS, datamodel_processProfile((char*)testJson, T2_RP));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

//datamodel_processProfile success test
Expand All @@ -171,7 +170,7 @@ TEST_F(datamodelTestFixture, datamodel_processProfile_TRP)
EXPECT_CALL(*g_datamodelMock, ReportProfiles_ProcessReportProfilesBlob(_, _))
.Times(1);
EXPECT_EQ(T2ERROR_SUCCESS, datamodel_processProfile((char*)testJson, T2_TEMP_RP));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

//datamodel_processProfile failure test
Expand Down
Loading
Loading