Skip to content

Commit

Permalink
Merge branch 'azure-pipeline-tests' of https://github.com/andreasgers…
Browse files Browse the repository at this point in the history
…tmayr/pcp into andreasgerstmayr-azure-pipeline-tests
  • Loading branch information
natoscott committed May 15, 2019
2 parents 58de73a + 7ae91f6 commit a443e1f
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![PCP](images/pcpicon.png)

[![Build Status](https://travis-ci.org/performancecopilot/pcp.svg?branch=master)](https://travis-ci.org/performancecopilot/pcp)
[![Build Status](https://dev.azure.com/performancecopilot/pcp/_apis/build/status/performancecopilot.pcp?branchName=master)](https://dev.azure.com/performancecopilot/pcp/_build/latest?definitionId=1&branchName=master)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/15853/badge.svg)](https://scan.coverity.com/projects/15853)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1872/badge)](https://bestpractices.coreinfrastructure.org/projects/1872)
[![Github Release](https://img.shields.io/github/release/performancecopilot/pcp.svg)](https://github.com/performancecopilot/pcp/releases/latest)
Expand Down
33 changes: 33 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
jobs:
- job: fedora30
displayName: Fedora 30
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build/containers/qa/qa.yml
parameters:
distribution: fedora30
- job: fedora_rawhide
displayName: Fedora Rawhide
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build/containers/qa/qa.yml
parameters:
distribution: fedora-rawhide
- job: debian_stable
displayName: Debian Stable
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build/containers/qa/qa.yml
parameters:
distribution: debian-stable
- job: debian_testing
displayName: Debian Testing
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build/containers/qa/qa.yml
parameters:
distribution: debian-testing
24 changes: 24 additions & 0 deletions build/containers/qa/Dockerfile.debian-stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:stable
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
pkg-config make gcc g++ libc6-dev flex bison \
sudo hostname findutils bc git cppcheck \
man procps \
perl \
python-dev python3 python3-dev pylint \
e2fsprogs xfsprogs systemd-sysv \
dpkg-dev gawk debhelper libreadline-dev chrpath python-all python3-all python-dev \
libnspr4-dev libnss3-dev libsasl2-dev libmicrohttpd-dev libavahi-common-dev \
zlib1g-dev libclass-dbi-perl libdbd-mysql-perl python3-psycopg2 libcairo2-dev \
libextutils-autoinstall-perl libxml-tokeparser-perl librrds-perl libjson-perl \
libwww-perl libnet-snmp-perl libnss3-tools \
python3-requests libspreadsheet-read-perl libdata-peek-perl time libncurses5-dev

RUN useradd -c "Performance Co-Pilot" -d /var/lib/pcp -M -r -s /usr/sbin/nologin pcp
COPY . /pcp

RUN cd /pcp && ./Makepkgs
RUN mkdir /packages && cd /packages && mv /pcp/build/deb/*.deb . && dpkg -i *.deb
RUN sed -ie '/\[Service\]/aTimeoutSec=120' /lib/systemd/system/{pmcd,pmlogger,pmie,pmproxy}.service
CMD ["/sbin/init"]
25 changes: 25 additions & 0 deletions build/containers/qa/Dockerfile.debian-testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM debian:testing
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
pkg-config make gcc g++ libc6-dev flex bison \
sudo hostname findutils bc git cppcheck \
man procps \
perl \
python2-dev python3 python3-dev pylint \
e2fsprogs xfsprogs systemd-sysv \
dpkg-dev gawk debhelper libreadline-dev chrpath python-all python3-all python-dev \
libnspr4-dev libnss3-dev libsasl2-dev libmicrohttpd-dev libavahi-common-dev \
zlib1g-dev libclass-dbi-perl libdbd-mysql-perl python3-psycopg2 libcairo2-dev \
libextutils-autoinstall-perl libxml-tokeparser-perl librrds-perl libjson-perl \
libwww-perl libnet-snmp-perl libnss3-tools \
python3-requests libspreadsheet-read-perl libdata-peek-perl time \
python3-bpfcc

RUN useradd -c "Performance Co-Pilot" -d /var/lib/pcp -M -r -s /usr/sbin/nologin pcp
COPY . /pcp

RUN cd /pcp && ./Makepkgs
RUN mkdir /packages && cd /packages && mv /pcp/build/deb/*.deb . && dpkg -i *.deb
RUN sed -ie '/\[Service\]/aTimeoutSec=120' /lib/systemd/system/{pmcd,pmlogger,pmie,pmproxy}.service
CMD ["/sbin/init"]
20 changes: 20 additions & 0 deletions build/containers/qa/Dockerfile.fedora-rawhide
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM fedora:rawhide

RUN dnf -y install \
pkg-config make gcc flex bison \
which sudo hostname findutils bc git cppcheck \
rpm-build redhat-rpm-config initscripts man procps \
avahi-devel ncurses-devel readline-devel zlib-devel \
perl perl-devel perl-generators perl-ExtUtils-MakeMaker \
python2-devel python3 python3-devel pylint \
bcc-tools e2fsprogs xfsprogs

COPY . /pcp
RUN cd /pcp && ./Makepkgs --check --verbose \
--without-qt --without-qt3d --without-webapi --without-manager
RUN mkdir /packages && cd /pcp/pcp-*/build/rpm && \
VER=$(pwd | cut -d- -f2 | cut -d/ -f1) && \
mv *-$VER-*.{x86_64,noarch}.rpm /packages
RUN cd /packages && dnf -y install *.rpm
RUN sed -ie '/\[Service\]/aTimeoutSec=120' /usr/lib/systemd/system/{pmcd,pmlogger,pmie,pmproxy}.service
CMD ["/usr/sbin/init"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:28
FROM fedora:30

RUN dnf -y install \
pkg-config make gcc flex bison \
Expand All @@ -12,7 +12,9 @@ RUN dnf -y install \
COPY . /pcp
RUN cd /pcp && ./Makepkgs --check --verbose \
--without-qt --without-qt3d --without-webapi --without-manager
RUN cd /pcp/pcp-*/build/rpm && VER=$(pwd | cut -d- -f2 | cut -d/ -f1) && \
dnf -y install *-$VER-*.{x86_64,noarch}.rpm
RUN mkdir /packages && cd /pcp/pcp-*/build/rpm && \
VER=$(pwd | cut -d- -f2 | cut -d/ -f1) && \
mv *-$VER-*.{x86_64,noarch}.rpm /packages
RUN cd /packages && dnf -y install *.rpm
RUN sed -ie '/\[Service\]/aTimeoutSec=120' /usr/lib/systemd/system/{pmcd,pmlogger,pmie,pmproxy}.service
CMD ["/usr/sbin/init"]
83 changes: 83 additions & 0 deletions build/containers/qa/gen_junit_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python
import sys
import os.path
import glob
import re
from xml.sax.saxutils import escape

def read_logfile(testsuite_path, no, ext):
fn = str(no) + '.' + ext
try:
with open(os.path.join(testsuite_path, fn)) as f:
return f.read()
except IOError as e:
return 'could not open {}: {}'.format(fn, e)

def parse_log_line(line, testsuite_path):
success_m = re.match(r'^\[\d+%\] (\d+)$', line)
notrun_m = re.match(r'^\[\d+%\] (\d+) \[not run\] (.+)$', line)
failed_m = re.match(r'^\[\d+%\] (\d+) (.+)$', line)
if success_m:
return {
"no": success_m.group(1),
"stdout": read_logfile(testsuite_path, success_m.group(1), "out")
}
elif notrun_m:
return {
"no": notrun_m.group(1),
"skipped": notrun_m.group(2),
"stdout": ""
}
elif failed_m:
return {
"no": failed_m.group(1),
"failed": failed_m.group(2).replace("- ", ""),
"failed_reason": read_logfile(testsuite_path, failed_m.group(1), "full"),
"stdout": read_logfile(testsuite_path, failed_m.group(1), "out.bad")
}
else:
return {}

def parse_testsuite(log_fn, testsuite_path):
testsuite = {
"name": os.path.splitext(os.path.basename(log_fn))[0],
"tests": []
}
with open(log_fn) as f:
for line in f:
test = parse_log_line(line.rstrip(), testsuite_path)
if test:
testsuite["tests"].append(test)
testsuite["tests_cnt"] = len(testsuite["tests"])
testsuite["skipped_cnt"] = len([test for test in testsuite["tests"] if "skipped" in test])
testsuite["failed_cnt"] = len([test for test in testsuite["tests"] if "failed" in test])
return testsuite

def create_report(log_path, testsuite_path):
testsuites = []
for fn in glob.glob(log_path + '/*.log'):
testsuites.append(parse_testsuite(fn, testsuite_path))

print('<?xml version="1.0" encoding="UTF-8"?>')
print('<testsuites>')

for testsuite in testsuites:
print('<testsuite name="{name}" tests="{tests_cnt}" skipped="{skipped_cnt}" failures="{failed_cnt}" errors="0">'.format(**testsuite))
for test in testsuite["tests"]:
print('<testcase classname="{no}" name="{no}">'.format(**test))
if "skipped" in test:
print('<skipped message="{skipped}"/>'.format(**test))
if "failed" in test:
print('<failure message="{failed}">{failed_reason}</failure>'.format(failed=test["failed"], failed_reason=escape(test["failed_reason"])))
print('<system-out>{stdout}</system-out>'.format(stdout=escape(test["stdout"])))
print('</testcase>')
print('</testsuite>')

print('</testsuites>')

if __name__ == '__main__':
if len(sys.argv) != 3:
print('usage: {} log_path testsuite_path'.format(sys.argv[0]))
sys.exit(1)

create_report(sys.argv[1], sys.argv[2])
35 changes: 35 additions & 0 deletions build/containers/qa/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
parameters:
distribution: ''

steps:
- script: |
docker build -f build/containers/qa/Dockerfile.${{ parameters.distribution }} -t pcp-qa .
docker run -d --privileged \
-v /lib/modules:/lib/modules:ro \
-v /usr/src:/usr/src:ro \
-v $(Build.ArtifactStagingDirectory):/artifacts \
--name pcp-qa pcp-qa
docker exec pcp-qa bash -c 'touch /var/lib/pcp/pmdas/{simple,sample}/.NeedInstall'
docker exec pcp-qa bash -c 'systemctl restart pmcd || journalctl -xe'
docker exec pcp-qa bash -c 'mkdir /artifacts/{test-logs,pcp-logs}'
displayName: 'Build Performance Co-Pilot'
- script: docker exec pcp-qa bash -c 'cd /var/lib/pcp/testsuite && ./check -g sanity | tee /artifacts/test-logs/sanity.log'
displayName: 'Run tests: Sanity'
- script: docker exec pcp-qa bash -c 'cd /var/lib/pcp/testsuite && ./check -g pmda.bcc | tee /artifacts/test-logs/pmda.bcc.log'
displayName: 'Run tests: BCC PMDA'
- script: |
docker exec pcp-qa bash -c 'cp -r /var/log/pcp/* /artifacts/pcp-logs'
docker exec pcp-qa bash -c 'cp -r /packages /artifacts'
docker exec pcp-qa bash -c 'python /pcp/build/containers/qa/gen_junit_report.py /artifacts/test-logs /var/lib/pcp/testsuite > /artifacts/test-logs/test.xml'
displayName: 'Copy artifacts'
- task: PublishTestResults@2
inputs:
testResultsFormat: JUnit
testResultsFiles: '*.xml'
searchFolder: '$(Build.ArtifactStagingDirectory)/test-logs'
failTaskOnFailedTests: true
testRunTitle: ${{ parameters.distribution }}
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: ${{ parameters.distribution }}
4 changes: 2 additions & 2 deletions src/pmrep/pmrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ def write_stdout_colxrow(self, timestamp):
found_insts = self.found_insts
self.found_insts = []
for sort_metric in self.sort_metric.split(","):
revs = True if sort_metric[:1] != "-" else False
revs = sort_metric[:1] != "-"
sort_metric = sort_metric if revs else sort_metric[1:]
for r in sorted(results[sort_metric], key=lambda x: x[2], reverse=revs):
if r[1] not in self.found_insts:
Expand Down Expand Up @@ -1354,7 +1354,7 @@ def overall_ranking(self, timestamp):
self.all_ranked[metric] = results[metric]
self.prev_insts = []

revs = True if self.rank > 0 else False
revs = self.rank > 0

for i, metric in enumerate(results):
if self.pmconfig.descs[i].contents.type == PM_TYPE_STRING:
Expand Down

0 comments on commit a443e1f

Please sign in to comment.