summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-10-10 10:12:44 +0300
committerLars Wirzenius <liw@liw.fi>2020-10-10 10:16:25 +0300
commit8be4a57cdb3851f127f1d91c56921d7ad58f36d6 (patch)
treebd63a903246399c58257454a2644ecafdde11d26
parentb2552e839c18a6831e258dc13f90e55643cfaa34 (diff)
downloaddebian-ansible-8be4a57cdb3851f127f1d91c56921d7ad58f36d6.tar.gz
test: make test configurable
Create test.cfg in the source tree for this. Currently, ./check does that with hardcoded values. I may change that later if need be, but this is simple for now.
-rw-r--r--.gitignore1
-rwxr-xr-xcheck9
-rw-r--r--subplot/subplot.py21
-rw-r--r--test.config1
-rw-r--r--test.key27
5 files changed, 25 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index b36d6fb..246e261 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
subplot.html
subplot.pdf
+test.cfg
test.log
test.md
test.py
diff --git a/check b/check
index 72acaa7..0fdede0 100755
--- a/check
+++ b/check
@@ -38,6 +38,15 @@ cat subplot/*.yaml roles/*/subplot.yaml > "$dir/subplot.yaml"
# Fix private key permissions. git doesn't preserve them.
chmod 0600 ssh/id
+# Create configuration for the test VMs used by the test suite.
+cat > test.cfg <<EOF
+name: debian-ansible-test
+base_image: "$HOME/tmp/debian-10-openstack-amd64.qcow2"
+username: debian
+cpus: 2
+memory: 1024
+EOF
+
$hideok python3 test.py --log test.log "$@"
echo "Everything seems to be in order."
diff --git a/subplot/subplot.py b/subplot/subplot.py
index c9c3cdc..1570d27 100644
--- a/subplot/subplot.py
+++ b/subplot/subplot.py
@@ -11,14 +11,23 @@ def create_vm(ctx):
QemuSystem = globals()["QemuSystem"]
srcdir = globals()["srcdir"]
- name = "debian-ansible-test"
- base_image = "/home/liw/tmp/debian-10-openstack-amd64.qcow2"
+ MiB = 1024 ** 2
GiB = 1024 ** 3
- disk_size = 10 * GiB
+
+ cfg = yaml.safe_load(open(os.path.join(srcdir, "test.cfg")))
+ name = cfg["name"]
+ base_image = cfg["base_image"]
+ username = cfg["username"]
+ cpus = cfg["cpus"]
+ memory = cfg["memory"] * MiB
+
+ # We use a hard-coded test key that we have in the source tree.
pubkey = open(os.path.join(srcdir, "ssh", "id.pub")).read().strip()
- memory = 1 * GiB
- cpus = 2
- username = "debian"
+
+ # We hard code the disk image size, since we don't expect scenarios to have
+ # any specific size needs, and also, the qcow2 image format is only as big
+ # as the data put into the disk, so we can choose a size that fits all.
+ disk_size = 10 * GiB
logging.info("starting a VM using qemu-system")
logging.info(f" name : {name}")
diff --git a/test.config b/test.config
deleted file mode 100644
index e1a73bb..0000000
--- a/test.config
+++ /dev/null
@@ -1 +0,0 @@
-image: /home/liw/tmp/debian-10-openstack-amd64.qcow2
diff --git a/test.key b/test.key
deleted file mode 100644
index 347f335..0000000
--- a/test.key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN OPENSSH PRIVATE KEY-----
-b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
-NhAAAAAwEAAQAAAQEAozhFGOsofrh7iVBOGqFOevAZ6UADRK9J78HhbZ3XGxjwDJ8/f3Ov
-XIELh+hhjWM1DlK+0qxEpEXJwoTiLlzHuA/HEqX8J5yApXkCvWNDamZNVqSDKpsP5gcaix
-KXFz2VaL3IGGumDzWuf8qtcJ3TAvVcpWAahLNEvV4HdQZBXL0bnnTYhc9cVSkWYGAKtwdm
-CBX5MkpTTFQpkHV300jF1s6Vbf6upDSP7xp2WrIzZ4CAKVV1mjpIrZx+zvszsv1Xfm+Zg4
-nekRFbmfehreiXHylzM5h4zkNhUBL+z/lr40/J1VeTzZKhyrwjzDgyd1CAI2mfU+Jgybax
-HQZ+Ke2ZTQAAA8iH8gOIh/IDiAAAAAdzc2gtcnNhAAABAQCjOEUY6yh+uHuJUE4aoU568B
-npQANEr0nvweFtndcbGPAMnz9/c69cgQuH6GGNYzUOUr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