diff options
author | Devaev Maxim <[email protected]> | 2019-05-01 00:32:35 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-05-01 00:32:35 +0300 |
commit | 374ff9cf9ea463b4d49227f89c5798d249330fd0 (patch) | |
tree | c9c8d71f5c3c52230ee5777a58421b342dea04b8 | |
parent | 84b68bd0a8ea1dbbeede284504cfa5d4d3e87bd8 (diff) |
test environment for ipmi
-rw-r--r-- | Makefile | 111 | ||||
-rw-r--r-- | testenv/main.yaml | 2 |
2 files changed, 59 insertions, 54 deletions
@@ -9,24 +9,29 @@ TESTENV_LOOP ?= /dev/loop7 # ===== all: @ echo "Useful commands:" - @ echo " make # Print this help" - @ echo " make tox # Run tests and linters" - @ echo " make tox E=pytest # Run selected test environment" - @ echo " make shell # Run shell in the docker test environment" - @ echo " make run # Run kvmd" - @ echo " make run CMD=... # Run specified command in the docker test environment" - @ echo " make regen # Regen some sources like keymap" - @ echo " make bump # Bump minor version" - @ echo " make bump V=major # Bump major version" - @ echo " make release # Publish the new release (include bump minor)" - @ echo " make clean # Remove garbage" - @ echo " make clean-all # Remove garbage and test results" + @ echo " make # Print this help" + @ echo " make textenv # Build test environment" + @ echo " make tox # Run tests and linters" + @ echo " make tox E=pytest # Run selected test environment" + @ echo " make run # Run kvmd" + @ echo " make run CMD=... # Run specified command inside kvmd environment" + @ echo " make run-ipmi # Run kvmd-ipmi" + @ echo " make run-ipmi CMD=... # Run specified command inside kvmd-ipmi environment" + @ echo " make regen # Regen some sources like keymap" + @ echo " make bump # Bump minor version" + @ echo " make bump V=major # Bump major version" + @ echo " make release # Publish the new release (include bump minor)" + @ echo " make clean # Remove garbage" + @ echo " make clean-all # Remove garbage and test results" @ echo @ echo "Also you can add option NC=1 to rebuild docker test environment" +testenv: + docker build $(if $(NC), --no-cache,) --rm --tag $(TESTENV_IMAGE) -f testenv/Dockerfile . + -tox: _testenv +tox: testenv time docker run --rm \ --volume `pwd`:/src:ro \ --volume `pwd`/testenv:/src/testenv:rw \ @@ -42,15 +47,49 @@ tox: _testenv " -run: - make _run_cmd CMD="$(if $(CMD), $(CMD), python -m kvmd.apps.kvmd)" +run: testenv + sudo modprobe loop + - docker run --rm --name kvmd \ + --volume `pwd`/testenv:/testenv:ro \ + --volume `pwd`/kvmd:/kvmd:ro \ + --volume `pwd`/web:/usr/share/kvmd/web:ro \ + --volume `pwd`/extras:/usr/share/kvmd/extras:ro \ + --volume `pwd`/configs:/usr/share/kvmd/configs.default:ro \ + --device $(TESTENV_LOOP):/dev/kvmd-msd \ + --device $(TESTENV_VIDEO):$(TESTENV_VIDEO) \ + --publish 8080:80/tcp \ + --publish 8081:8081/tcp \ + --publish 8082:8082/tcp \ + -it $(TESTENV_IMAGE) /bin/bash -c " \ + (socat PTY,link=$(TESTENV_HID) PTY,link=/dev/ttyS11 &) \ + && cp -r /usr/share/kvmd/configs.default/nginx/* /etc/kvmd/nginx \ + && cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ + && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ + && cp /testenv/main.yaml /etc/kvmd \ + && nginx -c /etc/kvmd/nginx/nginx.conf \ + && ln -s $(TESTENV_VIDEO) /dev/kvmd-video \ + && (losetup -d /dev/kvmd-msd || true) \ + && losetup /dev/kvmd-msd /root/loop.img \ + && $(if $(CMD), $(CMD), python -m kvmd.apps.kvmd) \ + " + - docker run --rm --device=$(TESTENV_LOOP):/dev/kvmd-msd -it $(TESTENV_IMAGE) losetup -d /dev/kvmd-msd -shell: - make _run_cmd CMD=/bin/bash +run-ipmi: testenv + - docker run --rm --name kvmd-ipmi --link kvmd:kvmd \ + --volume `pwd`/testenv:/testenv:ro \ + --volume `pwd`/kvmd:/kvmd:ro \ + --volume `pwd`/configs:/usr/share/kvmd/configs.default:ro \ + --publish 6230:623/udp \ + -it $(TESTENV_IMAGE) /bin/bash -c " \ + cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ + && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ + && cp /testenv/main.yaml /etc/kvmd \ + && $(if $(CMD), $(CMD), python -m kvmd.apps.ipmi) \ + " -regen: _testenv +regen: testenv for file in kvmd/data/keymap.yaml hid/src/keymap.h; do \ docker run --user `id -u`:`id -g` --rm \ --volume `pwd`:/src \ @@ -83,41 +122,7 @@ clean: make -C hid clean -clean-all: _testenv clean +clean-all: testenv clean - docker run --rm \ --volume `pwd`:/src \ -it $(TESTENV_IMAGE) bash -c "cd src && rm -rf testenv/{.tox,.mypy_cache,.coverage}" - - -# ===== -_testenv: - docker build $(if $(NC), --no-cache,) --rm --tag $(TESTENV_IMAGE) -f testenv/Dockerfile . - - -_run_cmd: _testenv - sudo modprobe loop - - docker run --rm \ - --volume `pwd`/testenv:/testenv:ro \ - --volume `pwd`/kvmd:/kvmd:ro \ - --volume `pwd`/web:/usr/share/kvmd/web:ro \ - --volume `pwd`/extras:/usr/share/kvmd/extras:ro \ - --volume `pwd`/configs:/usr/share/kvmd/configs.default:ro \ - --device $(TESTENV_LOOP):/dev/kvmd-msd \ - --device $(TESTENV_VIDEO):$(TESTENV_VIDEO) \ - --publish 8080:80/tcp \ - --publish 8081:8081/tcp \ - --publish 8082:8082/tcp \ - --publish 6230:623/udp \ - -it $(TESTENV_IMAGE) /bin/bash -c " \ - (socat PTY,link=$(TESTENV_HID) PTY,link=/dev/ttyS11 &) \ - && cp -r /usr/share/kvmd/configs.default/nginx/* /etc/kvmd/nginx \ - && cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ - && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ - && cp /testenv/main.yaml /etc/kvmd \ - && nginx -c /etc/kvmd/nginx/nginx.conf \ - && ln -s $(TESTENV_VIDEO) /dev/kvmd-video \ - && (losetup -d /dev/kvmd-msd || true) \ - && losetup /dev/kvmd-msd /root/loop.img \ - && $(if $(CMD), $(CMD), /bin/bash) \ - " - - docker run --rm --device=$(TESTENV_LOOP):/dev/kvmd-msd -it $(TESTENV_IMAGE) losetup -d /dev/kvmd-msd diff --git a/testenv/main.yaml b/testenv/main.yaml index 79138b9e..c9774f8d 100644 --- a/testenv/main.yaml +++ b/testenv/main.yaml @@ -39,7 +39,7 @@ kvmd: ipmi: kvmd: - host: 127.0.0.1 + host: kvmd port: 8081 logging: !include logging.yaml |