Skip to content

Commit

Permalink
[tests] Enable azure pipeline make check to respect unittests (sonic-…
Browse files Browse the repository at this point in the history
…net#760)

add check target for python module Makefile
fix all aspell errors
extract syslog in azure pipeline as artifact for debugging
enable make check to be respected in azure pipeline
  • Loading branch information
kcudnik authored Jan 27, 2021
1 parent b1edaef commit ad0f118
Show file tree
Hide file tree
Showing 19 changed files with 1,312 additions and 21 deletions.
92 changes: 92 additions & 0 deletions azsyslog.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html

#################
#### MODULES ####
#################

module(load="imuxsock") # provides support for local system logging
module(load="imklog") # provides kernel logging support
#module(load="immark") # provides --MARK-- message capability

# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")

# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")


###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
$ActionFileDefaultTemplate SONiCFileFormat

#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf


###############
#### RULES ####
###############

#
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log

#
# Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn
mail.err /var/log/mail.err

#
# Some "catch-all" log files.
#
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg :omusrmsg:*
76 changes: 71 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,35 @@ jobs:
fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic sairedis"
- script: |
make check || true
sudo cp azsyslog.conf /etc/rsyslog.conf
sudo service rsyslog restart
displayName: "Update rsyslog.conf"
- script: |
make check
displayName: "Run sonic sairedis unit tests"
- publish: $(System.DefaultWorkingDirectory)/
artifact: sonic-sairedis
displayName: "Archive sonic sairedis debian packages"
- script: |
pwd
sudo chmod a+r /var/log/syslog*
tar -czf syslog-all.tgz /var/log/syslog*
ls -al .
ls -al /var/log/
displayName: "Env info"
condition: always()
- task: CopyFiles@2
displayName: "Copy syslog to staging directory"
condition: always()
inputs:
contents: 'syslog-all.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
displayName: "Publish syslog artifacts"
condition: always()
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: sonic-sairedis.syslog.amd64

- job:
timeoutInMinutes: 180
Expand Down Expand Up @@ -136,11 +160,32 @@ jobs:
fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic sairedis"
- script: |
make check || true
displayName: "Run sonic sairedis unit tests"
sudo cp azsyslog.conf /etc/rsyslog.conf
sudo service rsyslog restart
displayName: "Update rsyslog.conf"
- publish: $(System.DefaultWorkingDirectory)/
artifact: sonic-sairedis.arm64
displayName: "Archive sonic sairedis debian packages"
- script: |
pwd
sudo chmod a+r /var/log/syslog*
tar -czf syslog-all.tgz /var/log/syslog*
ls -al .
ls -al /var/log/
displayName: "Env info"
condition: always()
- task: CopyFiles@2
displayName: "Copy syslog to staging directory"
condition: always()
inputs:
contents: 'syslog-all.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
displayName: "Publish syslog artifacts"
condition: always()
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: sonic-sairedis.syslog.arm64

- job:
timeoutInMinutes: 180
Expand Down Expand Up @@ -203,8 +248,29 @@ jobs:
fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic sairedis"
- script: |
make check || true
displayName: "Run sonic sairedis unit tests"
sudo cp azsyslog.conf /etc/rsyslog.conf
sudo service rsyslog restart
displayName: "Update rsyslog.conf"
- publish: $(System.DefaultWorkingDirectory)/
artifact: sonic-sairedis.armhf
displayName: "Archive sonic sairedis debian packages"
- script: |
pwd
sudo chmod a+r /var/log/syslog*
tar -czf syslog-all.tgz /var/log/syslog*
ls -al .
ls -al /var/log/
displayName: "Env info"
condition: always()
- task: CopyFiles@2
displayName: "Copy syslog to staging directory"
condition: always()
inputs:
contents: 'syslog-all.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
displayName: "Publish syslog artifacts"
condition: always()
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: sonic-sairedis.syslog.armhf
4 changes: 2 additions & 2 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ typedef enum _sai_redis_switch_attr_t
* running in synchronous mode. Command pipeline will be disabled when this
* flag will be set to true.
*
* NOTE: This attribute is depreacated by
* NOTE: This attribute is deprecated by
* SAI_REDIS_SWITCH_ATTR_REDIS_COMMUNICATION_MODE. When set to true it
* will set SAI_REDIS_SWITCH_ATTR_REDIS_COMMUNICATION_MODE to
* SAI_REDIS_COMMUNICATION_MODE_REDIS_SYNC.
Expand Down Expand Up @@ -197,7 +197,7 @@ typedef enum _sai_redis_switch_attr_t
/**
* @brief Recording log filename.
*
* Default valus is sairedis.rec
* Default value is sairedis.rec
*
* @type sai_s8_list_t
* @flags CREATE_AND_SET
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ sai_status_t Sai::set(
{
// skip metadata if attribute is redis extension attribute

// TODO this is setting on all contextes, but maybe we want one specific?
// TODO this is setting on all contexts, but maybe we want one specific?
// and do set on all if obejctId == NULL

bool success = true;
Expand Down
2 changes: 1 addition & 1 deletion meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace saimeta
{
public:

using sairedis::SaiInterface::set; // name hidding
using sairedis::SaiInterface::set; // name hiding

Meta(
_In_ std::shared_ptr<SaiInterface> impl);
Expand Down
4 changes: 2 additions & 2 deletions meta/MetaKeyHasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static bool operator==(
{
SWSS_LOG_ENTER();

// we can't use mem compare, since some fields will be padded and they
// we can't use memory compare, since some fields will be padded and they
// could contain garbage

return a.switch_id == b.switch_id &&
Expand Down Expand Up @@ -123,7 +123,7 @@ static_assert(sizeof(std::size_t) >= sizeof(uint32_t), "size_t must be at least
static inline std::size_t sai_get_hash(
_In_ const sai_route_entry_t& re)
{
// SWSS_LOG_ENTER(); // disabled for performance reasons
// SWSS_LOG_ENTER(); // disabled for performance reason

if (re.destination.addr_family == SAI_IP_ADDR_FAMILY_IPV4)
{
Expand Down
3 changes: 3 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ all: sairedis.cpp setup.py
install: all
python setup.py install --user

check:
true

.PHONY: clean

clean:
Expand Down
6 changes: 4 additions & 2 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ void FlexCounter::removePriorityGroup(
void FlexCounter::removeMACsecSA(
_In_ sai_object_id_t macsecSAVid)
{
SWSS_LOG_ENTER();

auto itr = m_macsecSAAttrIdsMap.find(macsecSAVid);

if (itr != m_macsecSAAttrIdsMap.end())
Expand All @@ -709,14 +711,12 @@ void FlexCounter::removeMACsecSA(
{
removeCollectCountersHandler(MACSEC_SA_ATTR_ID_LIST);
}

}
else
{
SWSS_LOG_WARN("Trying to remove nonexisting MACsec SA %s",
sai_serialize_object_id(macsecSAVid).c_str());
}

}

void FlexCounter::removeRif(
Expand Down Expand Up @@ -963,6 +963,8 @@ bool FlexCounter::isEmpty()

bool FlexCounter::isDiscarded()
{
SWSS_LOG_ENTER();

return isEmpty() && m_isDiscarded;
}

Expand Down
2 changes: 1 addition & 1 deletion syncd/NotificationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void NotificationProcessor::process_on_port_state_change(
}

/*
* Port may be in process of removal. OA may recieve notification for VID either
* Port may be in process of removal. OA may receive notification for VID either
* SAI_NULL_OBJECT_ID or non exist at time of processing
*/

Expand Down
4 changes: 2 additions & 2 deletions syncd/SaiAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ SaiAttr::SaiAttr(
if (m_meta->isenum && m_meta->enummetadata->ignorevalues)
{
// if attribute is enum, and we are loading some older SAI values it
// may happen that we get depreacated/ignored value string and we need
// may happen that we get deprecated/ignored value string and we need
// to update it to current one to not cause attribute compare confusion
// since they are compared by string value

auto val = sai_serialize_enum(m_attr.value.s32, m_meta->enummetadata);

if (val != m_str_attr_value)
{
SWSS_LOG_NOTICE("translating depreacated/ignore enum %s to %s",
SWSS_LOG_NOTICE("translating deprecated/ignore enum %s to %s",
m_str_attr_value.c_str(),
val.c_str());

Expand Down
6 changes: 6 additions & 0 deletions syncd/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ void test_watchdog_timer_clock_rollback()
{
SWSS_LOG_ENTER();

if (getuid() != 0)
{
SWSS_LOG_WARN("this test requires root for set time");
return;
}

const int64_t WARN_TIMESPAN_USEC = 30 * 1000000;
const uint8_t ROLLBACK_TIME_SEC = 5;
const uint8_t LONG_RUNNING_API_TIME_SEC = 3;
Expand Down
Loading

0 comments on commit ad0f118

Please sign in to comment.