Test single-node cluster (#78)
* Molecule: Derive overrides.yml location from scenario dir # Conflicts: # molecule/default/molecule.yml # molecule/ipv6/molecule.yml * Molecule: Add single_node scenario * Fix get_nodes test for the case of empty groups
This commit is contained in:
parent
b1df9663fa
commit
9ff3bb6b87
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -15,6 +15,8 @@ jobs:
|
||||
matrix:
|
||||
scenario:
|
||||
- default
|
||||
- single_node
|
||||
fail-fast: false
|
||||
env:
|
||||
PYTHON_VERSION: "3.10"
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ We have these scenarios:
|
||||
|
||||
- **default**:
|
||||
A 3 control + 2 worker node cluster based very closely on the [sample inventory](../inventory/sample/).
|
||||
- **single_node**:
|
||||
Very similar to the default scenario, but uses only a single node for all cluster functionality.
|
||||
|
||||
## How to execute
|
||||
|
||||
@ -29,7 +31,7 @@ Furthermore, the test cluster uses the `192.168.30.0/24` subnet which is [not se
|
||||
To set the subnet up for use with VirtualBox, please make sure that `/etc/vbox/networks.conf` exists and that it contains this line:
|
||||
|
||||
```
|
||||
* 192.168.30.0/24`
|
||||
* 192.168.30.0/24
|
||||
```
|
||||
|
||||
### Install Python dependencies
|
||||
|
||||
@ -53,8 +53,6 @@ provisioner:
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../inventory/sample/group_vars
|
||||
env:
|
||||
OVERRIDES_FILE: ../default/overrides.yml
|
||||
scenario:
|
||||
test_sequence:
|
||||
- dependency
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Apply overrides
|
||||
ansible.builtin.import_playbook: >-
|
||||
{{ lookup("ansible.builtin.env", "OVERRIDES_FILE") }}
|
||||
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
|
||||
|
||||
- name: Converge
|
||||
ansible.builtin.import_playbook: ../../site.yml
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Apply overrides
|
||||
ansible.builtin.import_playbook: >-
|
||||
{{ lookup("ansible.builtin.env", "OVERRIDES_FILE") }}
|
||||
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
|
||||
|
||||
- name: Reset
|
||||
ansible.builtin.import_playbook: ../../reset.yml
|
||||
|
||||
@ -12,6 +12,13 @@
|
||||
fail_msg: "Expected nodes {{ expected_nodes }}, but found nodes {{ found_nodes }}"
|
||||
vars:
|
||||
found_nodes: >-
|
||||
{{ cluster_nodes | json_query('resources[*].metadata.name') | unique }}
|
||||
expected_nodes: >-
|
||||
{{ (groups['master'] + groups['node']) | unique }}
|
||||
{{ cluster_nodes | json_query('resources[*].metadata.name') | unique | sort }}
|
||||
expected_nodes: |-
|
||||
{{
|
||||
(
|
||||
( groups['master'] | default([]) ) +
|
||||
( groups['node'] | default([]) )
|
||||
)
|
||||
| unique
|
||||
| sort
|
||||
}}
|
||||
|
||||
48
molecule/single_node/molecule.yml
Normal file
48
molecule/single_node/molecule.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: vagrant
|
||||
platforms:
|
||||
- name: control1
|
||||
box: generic/ubuntu2204
|
||||
memory: 4096
|
||||
cpus: 4
|
||||
config_options:
|
||||
# We currently can not use public-key based authentication on Ubuntu 22.04,
|
||||
# see: https://github.com/chef/bento/issues/1405
|
||||
ssh.username: "vagrant"
|
||||
ssh.password: "vagrant"
|
||||
groups:
|
||||
- k3s_cluster
|
||||
- master
|
||||
interfaces:
|
||||
- network_name: private_network
|
||||
ip: 192.168.30.50
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
converge: ../resources/converge.yml
|
||||
side_effect: ../resources/reset.yml
|
||||
verify: ../resources/verify.yml
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../inventory/sample/group_vars
|
||||
scenario:
|
||||
test_sequence:
|
||||
- dependency
|
||||
- lint
|
||||
- cleanup
|
||||
- destroy
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
# idempotence is not possible with the playbook in its current form.
|
||||
- verify
|
||||
# We are repurposing side_effect here to test the reset playbook.
|
||||
# This is why we do not run it before verify (which tests the cluster),
|
||||
# but after the verify step.
|
||||
- side_effect
|
||||
- cleanup
|
||||
- destroy
|
||||
15
molecule/single_node/overrides.yml
Normal file
15
molecule/single_node/overrides.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Apply overrides
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Override host variables
|
||||
ansible.builtin.set_fact:
|
||||
# See: https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant # noqa yaml[line-length]
|
||||
flannel_iface: eth1
|
||||
|
||||
# The test VMs might be a bit slow, so we give them more time to join the cluster:
|
||||
retry_count: 45
|
||||
|
||||
# Make sure that our IP ranges do not collide with those of the default scenario
|
||||
apiserver_endpoint: "192.168.30.223"
|
||||
metal_lb_ip_range: "192.168.30.91-192.168.30.99"
|
||||
Loading…
Reference in New Issue
Block a user