diff options
author | Parth Yadav <parthyadav3105@gmail.com> | 2021-07-19 19:26:06 +0530 |
---|---|---|
committer | Parth Yadav <parthyadav3105@gmail.com> | 2021-07-19 19:53:45 +0530 |
commit | 27cf386ac6a133b5c75d2dbe7864ec7166d74b09 (patch) | |
tree | 5f1338e8a360fef901d4c0d3c8612c06c99102c0 /sdv/docker/sdvstate/Makefile | |
parent | 3a0d5aa439389a42d1fc0cdcefdae2fe597c3e56 (diff) |
Initialize k8s test suite for Airship
This patch updates sdv framework to support multiple test suites.
Current test suites:
* default
* k8s
Current Cloud Installers:
* Airship
The patch also adds makefile for sdv framework to ease development work.
Some useful makefile target:
* make sandbox
* make run
* make lint
* make bash
Run `make help` for complete usage guide.
The patch restructures the codebases directory structure.
Signed-off-by: Parth Yadav<parthyadav3105@gmail.com>
Change-Id: I109d13f84334ec1cfa4f9c17b74d38a979272ea5
Diffstat (limited to 'sdv/docker/sdvstate/Makefile')
-rw-r--r-- | sdv/docker/sdvstate/Makefile | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/sdv/docker/sdvstate/Makefile b/sdv/docker/sdvstate/Makefile new file mode 100644 index 0000000..1cd9b78 --- /dev/null +++ b/sdv/docker/sdvstate/Makefile @@ -0,0 +1,133 @@ +# Set the shell to bash always +SHELL := /bin/bash + + +############# +# Options +############ + +IMG_TAG="latest" +WORKDIR="workdir" + +################### + +# helper for printing yellow-bold formatted messages in makefile. +# Usage: $S some text message $E +S=printf "\n\e[1;33m[makefile]: +E=\e[0m\n" + + +define HELP_MSG + +Usage: make [target] arguments=value +_________________________________________________________________ +Targets: + +make sandbox + creates new sandbox container. + +make sandbox-clean + deletes sandbox container. + +make build + builds container image for sdv. + +make bash + opens a bash to sandbox contianer + +make run + runs sdvstate checks inside sandbox container. + +make lint + lints sdvstate code and generates report. + +make setup-dev + creates workdir for local developement files. + +_________________________________________________________________ +Optional arguments: + +IMG_TAG + Currently set to '$(IMG_TAG)' + +endef +export HELP_MSG +help: + @echo "$$HELP_MSG" + + +# The following target enables all commands to run in same shell. This enables +# exit to kill the program +.ONESHELL: + + +define CONF +## Path to PDF file +PDF_FILE: github.com/nfvid/sites/blob/master/intel-pod10.json + +############# +# Airship arguments +############# + +# Path to kube-config file +KUBE_CONFIG : /sdv/workdir/example/config + +MASTER_ROLE_NAME : masters +WORKER_ROLE_NAME : workers +endef +export CONF +setup-dev: + @if [ ! -d "$(WORKDIR)" ]; then \ + mkdir $(WORKDIR); \ + mkdir "$(WORKDIR)/example"; \ + echo "$$CONF" >> "$(WORKDIR)/example/conf.yaml"; \ + $S: Created local workdir. $E; \ + fi + + +build: + $S: building sdv image... $E + @docker build . -t sdv:$(IMG_TAG) -f Dockerfile + + +sandbox-clean: + @if [[ "$(shell docker container ls --format "{{.Names}}" | grep sdvsandbox)" == "sdvsandbox" ]]; then \ + docker container stop sdvsandbox; \ + fi + +sandbox: build sandbox-clean + docker container run --rm -d --name sdvsandbox \ + -v $(PWD):/sdv/ \ + -v $(PWD)/workdir/result:/tmp/state \ + sdv:latest /bin/bash -c "while true; do sleep 10; done;"; + + +bash: + docker container exec -it sdvsandbox /bin/bash + +define sandbox_bash + if [[ "$(shell docker container ls --format "{{.Names}}" | grep sdvsandbox)" == "" ]]; then \ + echo "Sandbox container does not exists. Creating Sandbox..."; \ + make sandbox; \ + fi + docker container exec -it sdvsandbox bash -c $(1); +endef + +run: + @$(call sandbox_bash, "/sdv/state --conf-file /sdv/workdir/example/conf.yaml") + +lint: + @cp ../../../pylintrc $(WORKDIR)/pylintrc + @$(call sandbox_bash, \ + "pylint --rcfile=/sdv/workdir/pylintrc /sdv/state /sdv/server /sdv/internal /sdv/tools") + + +test: + @echo "Todo" + +all: help + + +.PHONY: help setup-dev build sandbox-clean sandbox bash lint test run all + + |