Skip to content

Commit

Permalink
Merge pull request #6775 from inverse-inc/feature/venom-1.0.0
Browse files Browse the repository at this point in the history
Feature/venom 1.0.0
  • Loading branch information
nqb committed Dec 23, 2021
2 parents 2b8f3cf + 774fb22 commit 280f23a
Show file tree
Hide file tree
Showing 149 changed files with 759 additions and 244 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
packetfence_install__centos_release_rpm: "http://packetfence.org/downloads/PacketFence/RHEL8/packetfence-release-{{ pf_minor_release }}.el8.noarch.rpm"

# in localdev environment: we install from official repositories
packetfence_install__centos:
repos:
- packetfence

# override to installed test files
packetfence_install__centos_packages:
- packetfence
Expand Down
2 changes: 1 addition & 1 deletion addons/vagrant/inventory/group_vars/pfservers/venom.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
venom__version: 'v1.0.0-rc.7'
venom__version: 'v1.0.1'

venom_dir: '/usr/local/pf/t/venom'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
venom__version: 'v1.0.0-rc.7'
venom__version: 'v1.0.1'

venom_dir: '/usr/local/pf/t/venom'

2 changes: 1 addition & 1 deletion addons/vagrant/playbooks/nodes/pre_prov/venom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- inverse_inc.utils

vars:
venom__version: 'v1.0.0-rc.7'
venom__version: 'v1.0.1'

roles:
- role: venom
Expand Down
2 changes: 1 addition & 1 deletion t/venom/.venomrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variables_files:
- vars/all.yml
- vars/local.yml
stop_on_failure: true
#format: tap
format: tap
output_dir: results
lib_dir: lib
verbosity: 1
5 changes: 5 additions & 0 deletions t/venom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,8 @@ example_deb11:
SCENARIOS_TO_RUN=example \
$(MAKE_TARGET)

test_deb11:
make \
PF_VM_NAME=pfdeb11$(DEV_ENV) \
SCENARIOS_TO_RUN=test_venom\
$(MAKE_TARGET)
2 changes: 1 addition & 1 deletion t/venom/install-venom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VENOM_BIN_PATH=/usr/bin
VENOM_BINARY=venom
ROOTUSER_NAME=root
VENOM_LATEST_URL=https://api.github.com/repos/ovh/venom/releases/latest
VENOM_DEFAULT_VERSION="1.0.0-rc.7"
VENOM_DEFAULT_VERSION="1.0.1"
VENOM_INSTALL_VERSION=${VENOM_VERSION:-${VENOM_DEFAULT_VERSION}}
VENOM_LATEST_VERSION=""
VENOM_INSTALLED_VERSION=""
Expand Down
12 changes: 12 additions & 0 deletions t/venom/lib/check_host_internet_access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
executor: check_host_internet_access
# By default it will use the node1
input:
host: "{{.node01_mgmt_ip}}"
user: "{{.ssh_user}}"
steps:
- type: ssh
host: '{{.input.host}}'
user: '{{.input.user}}'
command: |
cd '{{.venom_dir}}' ; \
sudo '{{.venom_dir}}/venom-wrapper.sh' '{{.test_suites_dir}}/common/check_internet_access.yml'
12 changes: 12 additions & 0 deletions t/venom/lib/check_internet_access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
executor: check_internet_access
input:
url: '{{.network_detection_url}}'
steps:
- type: http
method: GET
url: '{{.input.url}}'
assertions:
- result.statuscode ShouldEqual 200
# retry to let node get IP by DHCP
retry: 6
delay: 10
15 changes: 15 additions & 0 deletions t/venom/lib/customA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
executor: customA
input:
myArg: "world2"
steps:
- type: customB
myWord: "{{.input.myArg}}"
vars:
content:
from: result.foobarb
- script: echo "hello {{.content}}"
assertions:
- result.code ShouldEqual 0
- result.systemout ShouldContainSubstring "{{.input.myArg}}"
output:
foobarA: "{{.result.systemout}}"
10 changes: 10 additions & 0 deletions t/venom/lib/customB.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
executor: customB
input:
myWord: "world"
steps:
- script: echo "{{.input.myWord}}"
assertions:
- result.code ShouldEqual 0
- result.systemout ShouldContainSubstring "{{.input.myWord}}"
output:
foobarB: "{{.result.systemout}}"
14 changes: 14 additions & 0 deletions t/venom/lib/customC.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
executor: customC
input:
myarg: {
"name": "default",
"surname": "default2"
}
steps:
- script: echo "{{.input.myarg.name}}" > t.log
- script: echo "{\"hello\":\"{{.input.myarg.name}} and {{.input.myarg.surname}}\"}"
assertions:
- result.code ShouldEqual 0
output:
systemout: "{{.result.systemout}}"
systemoutjson.hello: "{{.result.systemoutjson.hello}}"
12 changes: 12 additions & 0 deletions t/venom/lib/customD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
executor: customD
input:
myArg: "world2"
steps:
- type: customB
myWord: "{{.input.myArg}}"
- script: echo "hello {{.result.foobarb}}"
assertions:
- result.code ShouldEqual 0
- result.systemout ShouldContainSubstring "{{.input.myArg}}"
output:
foobard: "{{.result.systemout}}"
20 changes: 20 additions & 0 deletions t/venom/lib/customE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
executor: customE
input:
myArg: "world2"
steps:
- type: customB
myWord: "{{.input.myArg}}"
vars:
varCustomB:
from: result.foobarb
- script: echo "hello {{.varCustomB}}"
assertions:
- result.code ShouldEqual 0
- result.systemout ShouldContainSubstring "{{.input.myArg}}"
- script: echo "hello you {{.varCustomB}}"
assertions:
- result.code ShouldEqual 0
- result.systemout ShouldContainSubstring "{{.input.myArg}}"
output:
foobarb: "{{.varcustomb}}"
foobare: "{{.result.systemout}}"
10 changes: 7 additions & 3 deletions t/venom/lib/delete_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ executor: delete_node
input:
mac_address: {}
mac_address_url_encoded: {}
token: {}
steps:
# Get token
- type: get_login_token
vars:
token:
from: result.token
# delete_node
- type: http
method: DELETE
url: '{{.pfserver_webadmin_url}}/api/v1/node/{{.input.mac_address_url_encoded}}'
ignore_verify_ssl: true
headers:
"Authorization": "{{.input.token}}"
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
Expand All @@ -22,7 +26,7 @@ steps:
url: '{{.pfserver_webadmin_url}}/api/v1/node/{{.input.mac_address_url_encoded}}'
ignore_verify_ssl: true
headers:
"Authorization": "{{.input.token}}"
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 404
Expand Down
11 changes: 11 additions & 0 deletions t/venom/lib/foobarcustommultisteps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
executor: foobarcustommultisteps
input: {}
steps:
- script: echo "hello"
vars:
content:
from: result.systemout
- script: echo "{{.content}} world"
output:
foobar: "{{.result.systemout}}"
contento: "{{.content}}"
7 changes: 7 additions & 0 deletions t/venom/lib/haproxy_admin_restart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
executor: haproxy-admin_restart
input:
myarg: {}
steps:
# service restarted by hand because using API cause Venom failure (EOF)
- type: restart_systemctl_service
service: packetfence-haproxy-admin
19 changes: 19 additions & 0 deletions t/venom/lib/haproxy_admin_restart_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
executor: haproxy-admini_restart_api
input:
myArg: {}
# service restarted by hand because using API cause Venom failure (EOF)
steps:
- type: get_login_token

- type: http
method: POST
url: '{{.pfserver_webadmin_url}}/api/v1/service/haproxy-admin/restart'
ignore_verify_ssl: true
headers:
"Authorization": "{{.result.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200

- type: sleep
time_to_sleep: 5
33 changes: 33 additions & 0 deletions t/venom/lib/node_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
executor: delete_node
input:
mac_address: {}
mac_address_url_encoded: {}
steps:
# Get token
- type: get_login_token
vars:
token:
from: result.token
# delete_node
- type: http
method: DELETE
url: '{{.pfserver_webadmin_url}}/api/v1/node/{{.input.mac_address_url_encoded}}'
ignore_verify_ssl: true
headers:
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.message ShouldEqual "Deleted {{.input.mac_address}} successfully"

# check node deleted
- type: http
method: GET
url: '{{.pfserver_webadmin_url}}/api/v1/node/{{.input.mac_address_url_encoded}}'
ignore_verify_ssl: true
headers:
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 404
- result.bodyjson.message ShouldEqual "Unable to get resource with this identifier"
5 changes: 5 additions & 0 deletions t/venom/lib/node_disable_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
executor: enable_node_cleanup

steps:
- type: node_task_cleanup
status: "disable"
5 changes: 5 additions & 0 deletions t/venom/lib/node_enable_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
executor: enable_node_cleanup

steps:
- type: node_task_cleanup
status: "enable"
42 changes: 42 additions & 0 deletions t/venom/lib/node_task_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
executor: node_task_cleanup
input:
status: "enabled"
interval: "{{.node_cleanup.delete_window.interval}}"
unit: "{{.node_cleanup.delete_window.unit}}"

steps:
- type: get_login_token
vars:
token:
from: result.token

- type: http
method: PATCH
url: '{{.pfserver_webadmin_url}}/api/v1/config/maintenance_task/node_cleanup'
ignore_verify_ssl: true
body: >-
{
"status": "{{.input.status}}"
}
headers:
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200

- type: http
method: PATCH
url: '{{.pfserver_webadmin_url}}/api/v1/config/maintenance_task/node_cleanup'
ignore_verify_ssl: true
body: >-
{
"delete_window": {
"interval": "{{.input.interval}}",
"unit": "{{.input.unit}}"
}
}
headers:
"Authorization": "{{.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
21 changes: 21 additions & 0 deletions t/venom/lib/pf_api_service_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
executor: pf_api_service_action
input:
service: {}
action: {}
steps:
- type: get_login_token

- type: http
method: POST
url: '{{.pfserver_webadmin_url}}/api/v1/service/{{.input.service}}/{{.input.action}}'
ignore_verify_ssl: true
headers:
"Authorization": "{{.result.token}}"
"Content-Type": "application/json"
assertions:
- result.statuscode ShouldEqual 200
output:
postjson: "{{.result.bodyjson}}"

- type: sleep
time_to_sleep: 5
10 changes: 10 additions & 0 deletions t/venom/lib/pf_api_service_disable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
executor: pf_api_service_disable
input:
service: {}
steps:
- type: pf_api_service_action
service: "{{.input.service}}"
action: "disable"

- type: sleep
time_to_sleep: 5
10 changes: 10 additions & 0 deletions t/venom/lib/pf_api_service_enable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
executor: pf_api_service_enable
input:
service: {}
steps:
- type: pf_api_service_action
service: "{{.input.service}}"
action: "enable"

- type: sleep
time_to_sleep: 5
10 changes: 10 additions & 0 deletions t/venom/lib/pf_api_service_restart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
executor: pf_api_service_restart
input:
service: {}
steps:
- type: pf_api_service_action
service: "{{.input.service}}"
action: "restart"

- type: sleep
time_to_sleep: 5
10 changes: 10 additions & 0 deletions t/venom/lib/pf_api_service_start.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
executor: pf_api_service_start
input:
service: {}
steps:
- type: pf_api_service_action
service: "{{.input.service}}"
action: "start"

- type: sleep
time_to_sleep: 5
9 changes: 9 additions & 0 deletions t/venom/lib/pf_api_service_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
executor: pf_api_service_status
input:
service: {}
steps:
- type: pf_api_service_action
service: "{{.input.service}}"
action: "status"
output:
postjson: "{{.result.postjson}}"
Loading

0 comments on commit 280f23a

Please sign in to comment.