Skip to content

Commit

Permalink
RTC-12004 Missing error handling in OS stats (#30)
Browse files Browse the repository at this point in the history
* Handle error case in proc file reading

* Disabled flaky test

* Move PR runners to single jenkins file
  • Loading branch information
Marcus Spangenberg authored Dec 1, 2021
1 parent 1a4da58 commit b800699
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 85 deletions.
49 changes: 32 additions & 17 deletions Jenkins/PRUnitTestRunner.groovy
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
void run(String cmakeBuildType) {
docker.image('gcr.io/sym-dev-rtc/buildsmb7:latest').inside {
stage("Build centos7 [$cmakeBuildType]") {
@Library('SFE-RTC-pipeline') _

void prRunner(String cmakeBuildType) {
stage("Checkout") {
checkout scm
}

stage("Build and test") {
docker.image('gcr.io/sym-dev-rtc/buildsmb-el7:latest').inside {
env.GIT_COMMITTER_NAME = "Jenkins deployment job"
env.GIT_COMMITTER_EMAIL = "jenkinsauto@symphony.com"
sh "docker/el7/buildscript.sh $cmakeBuildType"
sh "docker/el7/runtests.sh"
}
}
}

try {
docker.image('gcr.io/sym-dev-rtc/buildsmb7:latest').inside {
stage('Run tests centos7') {
sh "docker/el7/runtests.sh"
}
}
} finally {
stage("Post Actions") {
dir ("el7/smb") {
junit testResults: "test-results.xml"
abortPreviousRunningBuilds()

hasCoverage = (cmakeBuildType == "DCheck");
if (hasCoverage) {
parallel "Release": {
node('be-integration') {
prRunner("Release")
}
}, "LCheck": {
node('be-integration') {
prRunner("LCheck")
}
}, "TCheck": {
node('be-integration') {
prRunner("TCheck")
}
}, "DCheck": {
node('be-integration') {
try {
prRunner("DCheck")
} finally {
stage("Post Actions") {
dir ("el7/smb") {
junit testResults: "test-results.xml"
publishHTML(target: [
allowMissing : false,
alwaysLinkToLastBuild: false,
Expand All @@ -33,5 +50,3 @@ void run(String cmakeBuildType) {
}
}
}

return this
15 changes: 0 additions & 15 deletions Jenkins/PRUnitTestRunnerAddressSanitizerCoverage.groovy

This file was deleted.

15 changes: 0 additions & 15 deletions Jenkins/PRUnitTestRunnerLeakSanitizer.groovy

This file was deleted.

15 changes: 0 additions & 15 deletions Jenkins/PRUnitTestRunnerRelease.groovy

This file was deleted.

15 changes: 0 additions & 15 deletions Jenkins/PRUnitTestRunnerThreadSanitizer.groovy

This file was deleted.

25 changes: 19 additions & 6 deletions bridge/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,21 @@ SystemStatsCollector::SystemCpu operator-(SystemStatsCollector::SystemCpu a, con
return a;
}

bool SystemStatsCollector::readProcStat(FILE* h, ProcStat& stat) const
bool SystemStatsCollector::readProcStat(FILE* file, ProcStat& stat) const
{
if (!file)
{
return false;
}

char procName[30];
unsigned long long dummyull;
unsigned long dummy;
char state = 'M';
ProcStat sample;

auto procInfoRead = (24 ==
fscanf(h,
fscanf(file,
"%d %28s %c %lu %lu %lu %lu %lu"
" %lu %lu %lu %lu %lu %lu %lu %ld"
" %ld %ld %ld %ld %lu %llu %lu %ld",
Expand Down Expand Up @@ -339,17 +344,24 @@ ConnectionsStats SystemStatsCollector::collectNetStats()

namespace
{
void readSocketInfo(FILE* fh, uid_t myUid, uint32_t& count)

void readSocketInfo(FILE* file, uid_t myUid, uint32_t& count)
{
if (!file)
{
count = 0;
return;
}

uint32_t port = 0;
char ignore[513];
uid_t uid;
const char* formatString = "%*d: %*32[^:]:%x %*32[^:]:%*x %*x %*8[^:]:%*8s %*x:%*x %*x %u";
fgets(ignore, sizeof(ignore), fh);
fgets(ignore, sizeof(ignore), file);
for (int i = 0; i < 500; ++i)
{
int items = fscanf(fh, formatString, &port, &uid);
fgets(ignore, sizeof(ignore), fh);
int items = fscanf(file, formatString, &port, &uid);
fgets(ignore, sizeof(ignore), file);
if (items >= 2 && uid == myUid)
{
++count;
Expand All @@ -360,6 +372,7 @@ void readSocketInfo(FILE* fh, uid_t myUid, uint32_t& count)
}
}
}

} // namespace

ConnectionsStats SystemStatsCollector::collectLinuxNetStat()
Expand Down
2 changes: 1 addition & 1 deletion bridge/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SystemStatsCollector
SystemCpu systemSample;
};

bool readProcStat(FILE* h, ProcStat& stat) const;
bool readProcStat(FILE* file, ProcStat& stat) const;
bool readSystemStat(FILE* h, SystemCpu& stat) const;

std::atomic_flag _collectingStats = ATOMIC_FLAG_INIT;
Expand Down
2 changes: 1 addition & 1 deletion test/transport/RtcTransportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ bool areAllConnected(std::vector<std::unique_ptr<ClientPair>>& testPairs)
return true;
}

TEST_P(RtcTransportTest, packetLoad)
TEST_P(RtcTransportTest, DISABLED_packetLoad)
{
const int CLIENT_COUNT = std::get<0>(GetParam());
const bool enableIce = std::get<1>(GetParam());
Expand Down

0 comments on commit b800699

Please sign in to comment.