Skip to content

Commit

Permalink
Merge pull request #6769 from inverse-inc/test/inlinel3
Browse files Browse the repository at this point in the history
Test suites for inlinel2 and inlinel3
  • Loading branch information
nqb committed Jan 6, 2022
2 parents e2b3da4 + 0cfebe0 commit 7346269
Show file tree
Hide file tree
Showing 44 changed files with 2,366 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,22 @@ captive_portal_deb11:
- .test_script_job
- .test_devel_branches_and_maintenance_rules

inline_deb11:
variables:
VAGRANT_PF_DOTFILE_PATH: /var/local/gitlab-runner/vagrant/vagrant-${CI_COMMIT_TAG}
extends:
- .test_job
- .test_script_job
- .test_devel_branches_and_maintenance_rules

inline_el8:
variables:
VAGRANT_PF_DOTFILE_PATH: /var/local/gitlab-runner/vagrant/vagrant-${CI_COMMIT_TAG}
extends:
- .test_job
- .test_script_job
- .test_devel_branches_and_maintenance_rules

### release
configurator_el8:
variables:
Expand Down
12 changes: 12 additions & 0 deletions t/venom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ dot1x_eap_tls_deb11:
SCENARIOS_TO_RUN=dot1x_eap_tls \
$(MAKE_TARGET)

inline_deb11:
make \
PF_VM_NAME=pfdeb11$(DEV_ENV) \
SCENARIOS_TO_RUN=inline \
$(MAKE_TARGET)

inline_el8:
make \
PF_VM_NAME=pfel8$(DEV_ENV) \
SCENARIOS_TO_RUN=inline \
$(MAKE_TARGET)

fingerbank_invalid_db_deb11:
make \
PF_VM_NAME=pfdeb11$(DEV_ENV) \
Expand Down
25 changes: 25 additions & 0 deletions t/venom/scenarios/inline/playbooks/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- hosts: pfservers
name: configure Packetfence VM
become: True

tasks:
- name: Install qemu-system-x86 on debian
apt:
name: qemu-system-x86
state: present
when: ansible_facts['os_family'] == "Debian"

- name: Install qemu-kvm on el8
yum:
name: qemu-kvm
state: present
enablerepo: "epel"
when: ansible_facts['os_family'] == "RedHat"

- name: For RHEL8Create a symbolic link for qemu-system-x86_64
ansible.builtin.file:
src: /usr/libexec/qemu-kvm
dest: /usr/bin/qemu-system-x86_64
state: link
when: ansible_facts['os_family'] == "RedHat"
18 changes: 18 additions & 0 deletions t/venom/scenarios/inline/playbooks/rsync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- hosts: pfservers, service_venom, nodes
name: Rsync Git repository t/venom with /usr/local/pf/t/venom (localdev only)
become: True

tasks:
- name: Synchronize Git repository t/venom with /usr/local/pf/t/venom
ansible.posix.synchronize:
# src is provided through test-wrapper.sh
# as $PWD/venom (no leading slash)
src: "{{ lookup('env', 'VENOM_ROOT_DIR') }}"
dest: '/usr/local/pf/t/'
archive: yes
delete: yes
# exclude files dynamically generated by Ansible
rsync_opts:
- "--exclude=vars/local.yml"

34 changes: 34 additions & 0 deletions t/venom/scenarios/inline/playbooks/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- hosts: pfservers
name: Run example tests
become: True

vars:
# put your test suites to try here
test_suites:
- configurator_inline
- inline/l3
- inline/l3/teardown
- inline/l2
- inline/l2/teardown

tasks:
- name: Run Venom testsuites
command: '{{ venom_dir }}/venom-wrapper.sh {{ venom_dir }}/test_suites/{{ item }}'
args:
chdir: '{{ venom_dir }}'
loop: '{{ test_suites }}'
vars:
venom_wrapper_args:
# temp, overcome two Venom issues:
# - tap: https://github.com/ovh/venom/issues/428
# - when running test suite one by one, previous logs and results are overriden
# Venom will create one directory per test suite to store results
VENOM_COMMON_FLAGS: '--format=tap --output-dir={{ venom_dir }}/results/{{ item }}'

# add inventory__group_environment to Ansible environment
# useful to make env vars available for Venom
environment: '{{ inventory__group_environment | d({})
| combine(venom_wrapper_args | d({})) }}'


10 changes: 10 additions & 0 deletions t/venom/scenarios/inline/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# - import_playbook: playbooks/provision.yml

# rsync before tests when doing local development
- import_playbook: playbooks/rsync.yml
when: lookup("env", "CI") != 'true'

- import_playbook: playbooks/configure.yml

- import_playbook: playbooks/run_tests.yml
1 change: 0 additions & 1 deletion t/venom/scenarios/unit_tests/playbooks/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
- backup_db_and_restore
- backup_db_and_restore/teardown


tasks:
# only to debug what is injected in Ansible environment
# - name: Display ansible_env
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Configure DHCP listener interface
testcases:
# get_name_of: one-liner to get name (ex: eth0) based on index (ex: 1, 2)
- name: get_name_of_dhcp_listener_int
steps:
- type: exec
script: "ip -o link show | egrep -v '^1:' | grep '^{{.configurator.interfaces.dhcp_listener.index}}' | awk -F ': ' '{print $2;}'"
vars:
dhcp_listener_interface:
from: result.systemout

- name: configure_dhcp_listener_int
steps:
- type: http
method: PATCH
url: '{{.pfserver_webadmin_url}}/api/v1/configurator/config/interface/{{.get_name_of_dhcp_listener_int.dhcp_listener_interface}}'
ignore_verify_ssl: true
body: >-
{
"ipaddress": "{{.configurator.interfaces.dhcp_listener.ip}}",
"netmask": "{{.configurator.interfaces.dhcp_listener.netmask}}",
"type": "dhcp-listener"
}
headers:
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200

# switch interface to static state
- name: bounce_dhcp_listener_int
steps:
- type: http
method: POST
url: '{{.pfserver_webadmin_url}}/api/v1/configurator/config/interface/{{.get_name_of_dhcp_listener_int.dhcp_listener_interface}}/down'
ignore_verify_ssl: true
headers:
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.message ShouldEqual "Interface {{.get_name_of_dhcp_listener_int.dhcp_listener_interface}} disabled"

- type: http
method: POST
url: '{{.pfserver_webadmin_url}}/api/v1/configurator/config/interface/{{.get_name_of_dhcp_listener_int.dhcp_listener_interface}}/up'
ignore_verify_ssl: true
headers:
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.message ShouldEqual "Interface {{.get_name_of_dhcp_listener_int.dhcp_listener_interface}} enabled"

# start dhclient without any action on /etc/resolv.conf
- name: start_dhclient_on_dhcp_listener_int
steps:
- type: exec
script: "echo 'make_resolv_conf() { :; }' > /etc/dhcp/dhclient-enter-hooks"

- type: exec
script: "/usr/sbin/dhclient -nw {{.get_name_of_dhcp_listener_int.dhcp_listener_interface}}"


Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run configurator step 1
testcases:
# get_name_of: one-liner to get name (ex: eth0) based on index (ex: 1, 2)
- name: get_name_of_mgmt_int
steps:
- type: exec
script: "ip -o link show | egrep -v '^1:' | grep '^{{.configurator.interfaces.mgmt.index}}' | awk -F ': ' '{print $2;}'"
vars:
mgmt_interface:
from: result.systemout

- name: configure_mgmt_int
steps:
- type: http
method: PATCH
url: '{{.pfserver_webadmin_url}}/api/v1/configurator/config/interface/{{.get_name_of_mgmt_int.mgmt_interface}}'
ignore_verify_ssl: true
body: >-
{
"ipaddress": "{{.configurator.interfaces.mgmt.ip}}",
"netmask": "{{.configurator.interfaces.mgmt.netmask}}",
"type": "management",
"additional_listening_daemons": ["portal"]
}
headers:
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200


- name: configure_dns_servers
steps:
- type: http
method: PUT
url: '{{.pfserver_webadmin_url}}/api/v1/configurator/config/system/dns_servers'
ignore_verify_ssl: true
body: >-
{
"dns_servers": ["{{.configurator.dns.primary_ip}}", "{{.configurator.dns.secondary_ip}}"]
}
headers:
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
Loading

0 comments on commit 7346269

Please sign in to comment.