Skip to content

Commit

Permalink
Add an integration test for ansible provisioning
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed May 8, 2024
1 parent 45ede80 commit f59b361
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ jobs:
sudo modprobe kvm
# `sudo usermod -aG kvm $(whoami)` does not take an effect on GHA
sudo chown $(whoami) /dev/kvm
- name: Install ansible-playbook
run: |
sudo apt-get install -y --no-install-recommends ansible
if: matrix.template == '../hack/test-templates/test-misc.yaml'
- name: "Show cache"
run: ./hack/debug-cache.sh
- name: "Test"
Expand Down
6 changes: 6 additions & 0 deletions hack/ansible-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: all
tasks:
- name: Create test file
file:
path: /tmp/ansible
state: touch
7 changes: 7 additions & 0 deletions hack/test-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ declare -A CHECKS=(
["disk"]=""
["user-v2"]=""
["mount-path-with-spaces"]=""
["provision-ansible"]=""
)

case "$NAME" in
Expand Down Expand Up @@ -62,6 +63,7 @@ case "$NAME" in
CHECKS["snapshot-online"]="1"
CHECKS["snapshot-offline"]="1"
CHECKS["mount-path-with-spaces"]="1"
CHECKS["provision-ansible"]="1"
;;
"net-user-v2")
CHECKS["port-forwards"]=""
Expand Down Expand Up @@ -143,6 +145,11 @@ if [[ -n ${CHECKS["mount-path-with-spaces"]} ]]; then
[ "$(limactl shell "$NAME" cat "/tmp/lima test dir with spaces/test file")" = "test file content" ]
fi

if [[ -n ${CHECKS["provision-ansible"]} ]]; then
INFO 'Testing that /tmp/ansible was created successfully on provision'
limactl shell "$NAME" test -e /tmp/ansible
fi

INFO "Testing proxy settings are imported"
got=$(limactl shell "$NAME" env | grep FTP_PROXY)
# Expected: FTP_PROXY is set in addition to ftp_proxy, localhost is replaced
Expand Down
4 changes: 4 additions & 0 deletions hack/test-templates/test-misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ mounts:
- location: "/tmp/lima"
writable: true

provision:
- mode: ansible
playbook: ./hack/ansible-test.yaml

# in order to use this example, you must first create the disk "data". run:
# $ limactl disk create data --size 10G
additionalDisks:
Expand Down

0 comments on commit f59b361

Please sign in to comment.