Skip to content

Commit

Permalink
Merge pull request #165 from baum/pytest
Browse files Browse the repository at this point in the history
CI workflow for existing pytest tests
  • Loading branch information
baum authored Aug 8, 2023
2 parents 1fd85ec + 007cf90 commit a49e86b
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 50 deletions.
122 changes: 111 additions & 11 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
name: "CI"
on:
push:
branches:
- devel
pull_request:
branches:
- devel
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
env:
HUGEPAGES: 256

jobs:
build-and-test:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# git submodule update --init --recursive
submodules: recursive

- name: Build container images
run: make build SVC="spdk nvmeof nvmeof-cli ceph"

- name: Save container images
run: |
. .env
docker save quay.io/ceph/nvmeof:$NVMEOF_VERSION > nvmeof.tar
docker save quay.io/ceph/nvmeof-cli:$NVMEOF_VERSION > nvmeof-cli.tar
docker save quay.io/ceph/vstart-cluster:$CEPH_VERSION > vstart-cluster.tar
- name: Upload container images
uses: actions/upload-artifact@v3
with:
name: images
path: |
nvmeof.tar
nvmeof-cli.tar
vstart-cluster.tar
- name: Build stand-alone packages (RPMs and Python wheel)
id: build-standalone-packages
run: |
Expand All @@ -39,9 +50,99 @@ jobs:
path: |
${{ env.EXPORT_DIR }}/**
pytest:
needs: build
strategy:
fail-fast: false
matrix:
test: ["cli", "state", "multi_gateway"]
runs-on: ubuntu-latest
env:
HUGEPAGES: 512 # for multi gateway test, approx 256 per gateway instance
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup huge pages
run: |
make setup HUGEPAGES=$HUGEPAGES
- name: Download container images
uses: actions/download-artifact@v3
with:
name: images

- name: Load container images
run: |
docker load < nvmeof.tar
docker load < vstart-cluster.tar
- name: Start ceph cluster
run: |
make up SVC=ceph OPTS="--detach"
- name: Wait for the ceph cluster container to become healthy
run: |
while true; do
container_status=$(docker inspect --format='{{.State.Health.Status}}' ceph)
if [[ $container_status == "healthy" ]]; then
break
else
# Wait for a specific time before checking again
sleep 1
echo -n .
fi
done
echo
- name: Create RBD image
run: |
echo "💁 ceph list pools:"
make exec SVC=ceph OPTS="-T" CMD="ceph osd lspools"
echo "💁 rbd create:"
make exec SVC=ceph OPTS="-T" CMD="rbd create rbd/mytestdevimage --size 16"
echo "💁 ls rbd:"
make exec SVC=ceph OPTS="-T" CMD="rbd ls rbd"
- name: Run ${{ matrix.test }} test
run: |
# Run tests code in current dir
# Managing pytest’s output: https://docs.pytest.org/en/7.1.x/how-to/output.html
make run SVC="nvmeof-devel" OPTS="--volume=$(pwd)/tests:/src/tests --entrypoint=python3" CMD="-m pytest --full-trace -vv -ra -s tests/test_${{ matrix.test }}.py"
- name: Display Logs
run: |
make logs OPTS=""
- name: Compose Down
run: make down

- name: Compose Clean
run: make clean

demo:
needs: build
runs-on: ubuntu-latest
env:
HUGEPAGES: 256
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup huge-pages
run: make setup HUGEPAGES=$HUGEPAGES

- name: Download container images
uses: actions/download-artifact@v3
with:
name: images

- name: Load container images
run: |
docker load < nvmeof.tar
docker load < nvmeof-cli.tar
docker load < vstart-cluster.tar
- name: Start containers
run: |
make up OPTS=--detach || (make logs OPTS=''; exit 1)
Expand All @@ -50,8 +151,8 @@ jobs:
timeout-minutes: 1
run: |
. .env
HOST_PORT=$(make -s port OPTS="--index=1" CMD="nvmeof $NVMEOF_GW_PORT" | tr ":" " ")
until nc -z $HOST_PORT; do
echo using gateway $NVMEOF_IP_ADDRESS port $NVMEOF_GW_PORT
until nc -z $NVMEOF_IP_ADDRESS $NVMEOF_GW_PORT; do
echo -n .
sleep 1
done
Expand All @@ -65,8 +166,7 @@ jobs:

- name: Test
run: |
. .env
make demo SERVER_ADDRESS=$NVMEOF_IP_ADDRESS OPTS=-T # Disable TTY
make demo OPTS=-T || (make logs OPTS=''; exit 1)
- name: Get subsystems
run: |
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ setup: ## Configure huge-pages (requires sudo/root password)
@echo Actual Hugepages allocation: $$(cat $(HUGEPAGES_DIR))
@[ $$(cat $(HUGEPAGES_DIR)) -eq $(HUGEPAGES) ]

build push pull: SVC ?= spdk nvmeof nvmeof-cli ceph
build push pull logs: SVC ?= spdk nvmeof nvmeof-cli ceph

build: export NVMEOF_GIT_BRANCH != git name-rev --name-only HEAD
build: export NVMEOF_GIT_COMMIT != git rev-parse HEAD
Expand All @@ -27,9 +27,10 @@ build: export SPDK_GIT_BRANCH != git -C spdk name-rev --name-only HEAD
build: export SPDK_GIT_COMMIT != git rev-parse HEAD:spdk
build: export BUILD_DATE != date -u +"%Y-%m-%dT%H:%M:%SZ"

up: SVC = nvmeof ## Services
up: OPTS ?= --abort-on-container-exit
up: override OPTS += --no-build --remove-orphans --scale nvmeof=$(SCALE)
up: ## Launch services
up: SVC ?= ceph nvmeof ## Services
up: OPTS ?= --abort-on-container-exit --exit-code-from $(SVC) --remove-orphans
up: override OPTS += --scale nvmeof=$(SCALE)

clean: override HUGEPAGES = 0
clean: $(CLEAN) setup ## Clean-up environment
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![CI](https://github.com/ceph/ceph-nvmeof/actions/workflows/build-container.yml/badge.svg)](https://github.com/ceph/ceph-nvmeof/actions/workflows/build-container.yml)
# Ceph NVMe over Fabrics (NVMe-oF) Gateway

This project provides block storage on top of Ceph for platforms (e.g.: VMWare) without
Expand Down
2 changes: 1 addition & 1 deletion ceph-nvmeof.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[gateway]
name =
group =
addr = 192.168.13.3
addr = 0.0.0.0
port = 5500
enable_auth = False
state_update_notify = True
Expand Down
6 changes: 1 addition & 5 deletions mk/containerized.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ DOCKER_COMPOSE = docker-compose ## Docker-compose command
DOCKER_COMPOSE_COMMANDS = pull build push up run exec ps top images logs port \
pause unpause stop restart down events

SVC ?= ## Docker-compose services
OPTS ?= ## Docker-compose subcommand options
SCALE ?= 1 ## Number of instances
CMD ?= ## Command to run with run/exec targets
Expand All @@ -22,10 +21,7 @@ build: DOCKER_COMPOSE_ENV = DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1

push: ## Push SVC container images to a registry. Requires previous "docker login"

up: ## Launch services

run: ## Run command CMD inside SVC containers
run: SVC ?=
run: override OPTS += --rm
run: DOCKER_COMPOSE_ENV = DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1

Expand All @@ -43,7 +39,7 @@ port: ## Print public port for a port binding

logs: ## View SVC logs
logs: MAX_LOGS = 40
logs: OPTS += --follow --tail=$(MAX_LOGS)
logs: OPTS ?= --follow --tail=$(MAX_LOGS)

images: ## List images

Expand Down
73 changes: 72 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ maintainers = []
keywords = []
classifiers = [] # https://pypi.org/classifiers/
dependencies = [
"grpcio ~= 1.53.0",
"grpcio_tools ~= 1.53.0"
"grpcio ~= 1.53.0",
"grpcio_tools ~= 1.53.0",
"pytest>=7.4.0",
]

[tool.pdm.scripts]
Expand Down
Loading

0 comments on commit a49e86b

Please sign in to comment.