-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from ggiamarchi/integration-test
Integration tests
- Loading branch information
Showing
24 changed files
with
646 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,9 @@ test/tftp_root/pxelinux.cfg/01-* | |
# Binary tools localy installed | ||
# | ||
bin/ | ||
|
||
# | ||
# Vagrant things | ||
# | ||
.vagrant/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
ENV["LC_ALL"] = "en_US.UTF-8" | ||
|
||
Vagrant.configure(2) do |config| | ||
|
||
config.vm.box = "ubuntu/xenial64" | ||
|
||
config.vm.define "pxe-pilot" do |server| | ||
config.vm.provider 'virtualbox' do |vb| | ||
vb.customize ['modifyvm', :id, '--memory', '2048'] | ||
vb.customize ['modifyvm', :id, '--chipset', 'ich9'] | ||
end | ||
|
||
server.vm.hostname = 'pxe-pilot' | ||
|
||
server.vm.network "private_network", ip: "10.69.70.70", mac: "000000000a70" | ||
server.vm.network "private_network", ip: "10.69.71.70", mac: "000000000b70" | ||
|
||
server.vm.provision "shell", privileged: false, path: "test/scripts/install-tools.sh" | ||
server.vm.provision "shell", privileged: false, path: "test/scripts/install-go.sh" | ||
server.vm.provision "shell", privileged: false, path: "test/scripts/install-bats.sh" | ||
server.vm.provision "shell", privileged: false, path: "test/scripts/install-mocks.sh" | ||
server.vm.provision "shell", privileged: false, path: "test/scripts/build.sh" | ||
server.vm.provision "shell", privileged: false, path: "test/scripts/install-service.sh" | ||
|
||
# | ||
# Running tests | ||
# | ||
server.vm.provision "shell", privileged: false, inline: <<-SHELL | ||
set -e | ||
echo "##############################################################" | ||
echo "### Running integration tests ###" | ||
echo "##############################################################" | ||
/vagrant/test/run.bats | ||
SHELL | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pxe-pilot.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -e /tmp/arp-populated ]; then | ||
exit 0 | ||
fi | ||
|
||
echo "? (10.69.70.14) at 00:00:00:00:0a:04 [ether] on enp0s8 | ||
? (10.69.70.12) at 00:00:00:00:0a:02 [ether] on enp0s8 | ||
? (10.69.70.13) at 00:00:00:00:0a:03 [ether] on enp0s8 | ||
? (10.69.70.11) at 00:00:00:00:0a:01 [ether] on enp0s8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*/status |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
sleep 5 | ||
|
||
touch /tmp/arp-populated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
data=$(cat /etc/pxe-pilot/test-home)/mocks/data | ||
|
||
mkdir -p ${data} | ||
|
||
POSITIONAL=() | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
-I) | ||
: | ||
shift | ||
shift | ||
;; | ||
-P) | ||
: | ||
password=$2 | ||
shift | ||
shift | ||
;; | ||
-U) | ||
: | ||
username=$2 | ||
shift | ||
shift | ||
;; | ||
-N) | ||
: | ||
shift | ||
shift | ||
;; | ||
-R) | ||
: | ||
shift | ||
shift | ||
;; | ||
-H) | ||
host="$2" | ||
shift | ||
shift | ||
;; | ||
*) | ||
POSITIONAL+=("$1") | ||
shift | ||
: | ||
;; | ||
esac | ||
done | ||
|
||
if [ ! -d ${data}/${host} ]; then | ||
sleep 5 | ||
echo "Error: Unable to establish IPMI v2 / RMCP+ session" | ||
exit 1 | ||
fi | ||
|
||
if [ "${username}" != "user" ] || [ "${password}" != "password" ]; then | ||
echo "Error: Unable to establish IPMI v2 / RMCP+ session" | ||
exit 1 | ||
fi | ||
|
||
ipmi_cmd="${POSITIONAL[@]}" | ||
|
||
power_status() { | ||
local statusFile="${data}/${host}/status" | ||
|
||
if [ ! -e ${statusFile} ]; then | ||
echo "off" > ${statusFile} | ||
fi | ||
|
||
sleep .2 | ||
echo "Chassis Power is $(cat ${statusFile})" | ||
|
||
exit 0 | ||
} | ||
|
||
power_on() { | ||
sleep .2 | ||
local statusFile="${data}/${host}/status" | ||
echo "on" > ${statusFile} | ||
echo 'Chassis Power Control: Up/On' | ||
} | ||
|
||
power_off() { | ||
sleep .2 | ||
local statusFile="${data}/${host}/status" | ||
echo "off" > ${statusFile} | ||
echo 'Chassis Power Control: Down/Off' | ||
} | ||
|
||
power_reset() { | ||
sleep .2 | ||
local statusFile="${data}/${host}/status" | ||
echo 'Chassis Power Control: Reset' | ||
} | ||
|
||
[[ "${ipmi_cmd}" = "power status" || "${ipmi_cmd}" = "chassis power status" ]] && { | ||
power_status | ||
} | ||
|
||
[[ "${ipmi_cmd}" = "power on" || "${ipmi_cmd}" = "chassis power on" ]] && { | ||
power_on | ||
} | ||
|
||
[[ "${ipmi_cmd}" = "power off" || "${ipmi_cmd}" = "chassis power off" ]] && { | ||
power_off | ||
} | ||
|
||
[[ "${ipmi_cmd}" = "power reset" || "${ipmi_cmd}" = "chassis power reset" ]] && { | ||
power_reset | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
|
||
host_management_adapters: | ||
|
||
- name: ipmitool | ||
vars: | ||
- name: command | ||
value: ipmitool-mock -N 2 -R 2 -I lanplus -U user -P password -H {{.ip_address}} | ||
power_status: | ||
cmd: '{{.command}} power status' | ||
pattern_on: 'Chassis Power is on' | ||
pattern_off: 'Chassis Power is off' | ||
power_reset: | ||
cmd: '{{.command}} power reset' | ||
power_on: | ||
cmd: '{{.command}} power on' | ||
power_off: | ||
cmd: '{{.command}} power off' | ||
|
||
- name: ipmitool-with-variables | ||
vars: | ||
- name: command | ||
value: ipmitool-mock -N 2 -R 2 -I lanplus -U {{.username}} -P {{.password}} -H {{.ip_address}} | ||
power_status: | ||
cmd: '{{.command}} power status' | ||
pattern_on: 'Chassis Power is on' | ||
pattern_off: 'Chassis Power is off' | ||
power_reset: | ||
cmd: '{{.command}} power reset' | ||
power_on: | ||
cmd: '{{.command}} power on' | ||
power_off: | ||
cmd: '{{.command}} power off' | ||
|
||
hosts: | ||
|
||
- name: h1 | ||
mac_addresses: ["00:00:00:00:0b:01"] | ||
ipmi: | ||
mac_address: "00:00:00:00:0a:01" | ||
subnet: 10.69.70.0/24 | ||
username: "user" | ||
password: "password" | ||
interface: "lanplus" | ||
|
||
- name: h2 | ||
mac_addresses: ["00:00:00:00:0b:02"] | ||
management: | ||
mac_address: "00:00:00:00:0a:02" | ||
subnet: 10.69.70.0/24 | ||
adapter: ipmitool-with-variables | ||
vars: | ||
- name: username | ||
value: user | ||
- name: password | ||
value: password | ||
|
||
- name: h3 | ||
mac_addresses: ["00:00:00:00:0b:03", "00:00:00:00:0c:03", "00:00:00:00:0d:03"] | ||
|
||
- name: h4 | ||
mac_addresses: ["00:00:00:00:0b:04"] | ||
management: | ||
mac_address: "00:00:00:00:0a:04" | ||
subnet: 10.69.70.0/24 | ||
adapter: ipmitool | ||
|
||
tftp: | ||
root: "%%TFTP_ROOT%%" | ||
|
||
configuration: | ||
directory: "%%CONFIG_DIR%%" | ||
bootloaders: | ||
- name: pxelinux | ||
file: pxelinux.0 | ||
- name: syslinux | ||
file: syslinux.efi | ||
- name: grub | ||
file: grubnetx64.efi.signed | ||
config_path: grub/grub.cfg | ||
|
||
discovery: | ||
cmd: fping -c 1 -D -q -g {{.subnet}} | ||
|
||
arp: | ||
cmd: arp -an | ||
|
||
server: | ||
port: 3478 |
Oops, something went wrong.