forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sairedis] Perform log rotate on request (sonic-net#1058)
Previously log rotate was performed after request and on first log line that was recorded which caused delay and issues with syslog logrotate when sending HUP signal, actual log rotate was not performed and handle to a sairedis.rec was sill open preventing logrotate from happening.
- Loading branch information
Showing
3 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "Recorder.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
|
||
using namespace sairedis; | ||
|
||
TEST(Recorder, requestLogRotate) | ||
{ | ||
Recorder rec; | ||
|
||
rec.enableRecording(true); | ||
|
||
rec.recordComment("foo"); | ||
|
||
int code = rename("sairedis.rec", "sairedis.rec.1"); | ||
|
||
EXPECT_EQ(code, 0); | ||
|
||
EXPECT_NE(access("sairedis.rec", F_OK),0); | ||
|
||
rec.requestLogRotate(); | ||
|
||
EXPECT_EQ(access("sairedis.rec", F_OK),0); | ||
|
||
rec.recordComment("bar"); | ||
} |