Skip to content

Commit

Permalink
PBM gocoverage for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olexandr-havryliak committed Dec 16, 2024
1 parent 4f4aa96 commit 1cc3209
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/PBM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
PSMDB: ${{ github.event.inputs.psmdb || 'percona/percona-server-mongodb' }}
PBM_BRANCH: ${{ github.event.inputs.pbm_branch || 'dev' }}
GO_VER: ${{ github.event.inputs.go_ver || 'bullseye' }}
MAKE_TARGET: 'build-cover'
steps:
- uses: actions/checkout@v4
- name: Setup environment with PSMDB ${{ env.PSMDB }} and PBM branch ${{ env.PBM_BRANCH }}
Expand All @@ -36,6 +37,16 @@ jobs:
run: |
docker compose run --rm test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
working-directory: ./pbm-functional/pytest
- name: Print func coverage for ${{ matrix.test }} backup/restore PBM branch ${{ env.PBM_BRANCH }}
run: |
docker compose run --rm golang_reports go tool covdata func -i /gocoverdir/reports
working-directory: ./pbm-functional/pytest
if: success() || failure()
- name: Print percent coverage for ${{ matrix.test }} backup/restore PBM branch ${{ env.PBM_BRANCH }}
run: |
docker compose run --rm golang_reports go tool covdata percent -i /gocoverdir/reports
working-directory: ./pbm-functional/pytest
if: success() || failure()
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
Expand Down
5 changes: 3 additions & 2 deletions pbm-functional/pytest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ FROM pykmip/local AS pykmip
FROM golang:$GO_VER AS builder
ARG PBM_BRANCH=dev
ARG PR_NUMBER
ARG MAKE_TARGET=build
WORKDIR /
RUN mkdir -p /pbm-old && mkdir -p /pbm-new && \
apt update && apt -y install gcc libgssapi-krb5-2 libkrb5-dev libsasl2-modules-gssapi-mit && \
git clone https://github.com/percona/percona-backup-mongodb.git && cd percona-backup-mongodb && \
if [ -n "$PR_NUMBER" ]; then git fetch origin pull/$PR_NUMBER/head:CURRENT_PR; PBM_BRANCH=CURRENT_PR; fi && \
git checkout $PBM_BRANCH && \
make build && cp -rpf bin/* /pbm-new/ && rm -rf bin && \
make $MAKE_TARGET && cp -rpf bin/* /pbm-new/ && rm -rf bin && \
git reset --hard && \
git branch -r | grep release | sed 's/origin\///'| grep -v $PBM_BRANCH | sort --version-sort | tail -1 | xargs git checkout && \
git pull && \
make build && cp -rpf bin/* /pbm-old/ && rm -rf bin
make $MAKE_TARGET && cp -rpf bin/* /pbm-old/ && rm -rf bin

FROM $PSMDB
USER root
Expand Down
15 changes: 9 additions & 6 deletions pbm-functional/pytest/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ def create(self):
detach=True,
network='test',
environment=["PBM_MONGODB_URI=" + pbm_mongodb_uri, "DATADIR=" + self.mongod_datadir, "KRB5_KTNAME=/keytabs/" + host['host'] + "/mongodb.keytab",
"MONGODB_EXTRA_ARGS= --port 27017 --replSet " + self.config['_id'] + " --keyFile /etc/keyfile " + self.mongod_extra_args],
volumes=["fs:/backups","keytabs:/keytabs"]
"MONGODB_EXTRA_ARGS= --port 27017 --replSet " + self.config['_id'] + " --keyFile /etc/keyfile " + self.mongod_extra_args,
"GOCOVERDIR=/gocoverdir/reports"],
volumes=["fs:/backups","keytabs:/keytabs","gocoverdir:/gocoverdir"]
)
if "arbiterOnly" in host:
if host['arbiterOnly']:
Expand All @@ -288,8 +289,9 @@ def create(self):
detach=True,
network='test',
environment=["PBM_MONGODB_URI=" + pbm_mongodb_uri, "DATADIR=" + self.mongod_datadir, "KRB5_KTNAME=/keytabs/" + host['host'] + "/mongodb.keytab",
"MONGODB_EXTRA_ARGS= --port 27017 --replSet " + shard['_id'] + " --shardsvr --keyFile /etc/keyfile " + self.mongod_extra_args, "KRB5_TRACE=/dev/stderr"],
volumes=["fs:/backups","keytabs:/keytabs"]
"MONGODB_EXTRA_ARGS= --port 27017 --replSet " + shard['_id'] + " --shardsvr --keyFile /etc/keyfile " + self.mongod_extra_args, "KRB5_TRACE=/dev/stderr",
"GOCOVERDIR=/gocoverdir/reports"],
volumes=["fs:/backups","keytabs:/keytabs","gocoverdir:/gocoverdir"]
)
if 'arbiterOnly' in host:
if host['arbiterOnly']:
Expand All @@ -311,8 +313,9 @@ def create(self):
network='test',
environment=["PBM_MONGODB_URI=" + pbm_mongodb_uri, "DATADIR=" + self.mongod_datadir, "KRB5_KTNAME=/keytabs/" + host['host'] + "/mongodb.keytab",
"MONGODB_EXTRA_ARGS= --port 27017 --replSet " +
self.config['configserver']['_id'] + " --configsvr --keyFile /etc/keyfile " + self.mongod_extra_args],
volumes=["fs:/backups","keytabs:/keytabs"]
self.config['configserver']['_id'] + " --configsvr --keyFile /etc/keyfile " + self.mongod_extra_args,
"GOCOVERDIR=/gocoverdir/reports"],
volumes=["fs:/backups","keytabs:/keytabs","gocoverdir:/gocoverdir"]
)
if "arbiterOnly" in host:
if host['arbiterOnly']:
Expand Down
11 changes: 11 additions & 0 deletions pbm-functional/pytest/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,21 @@ services:
- GO_VER=${GO_VER:-bullseye}
- PSMDB=${PSMDB:-percona/percona-server-mongodb:latest}
- PR_NUMBER=${PR_NUMBER:-}
- MAKE_TARGET=${MAKE_TARGET:-build}
environment:
- "PERCONA_TELEMETRY_URL=https://check-dev.percona.com/v1/telemetry/GenericReport"
command: /bin/bash
depends_on:
- pykmip

golang_reports:
image: golang:bullseye
command: >
/bin/sh -c " mkdir -p /gocoverdir/reports; chmod -R 777 /gocoverdir/reports; exit 0; "
volumes:
- .:/test
- gocoverdir:/gocoverdir

networks:
test:
name: test
Expand All @@ -141,3 +150,5 @@ volumes:
name: fs
keytabs:
name: keytabs
gocoverdir:
name: gocoverdir

0 comments on commit 1cc3209

Please sign in to comment.