Skip to content

Commit 15626c9

Browse files
authored
Merge pull request #214 from intel-go/gregory/testing
Implemented stability tests and improved infra scripts
2 parents 084b404 + c8cdd2e commit 15626c9

File tree

6 files changed

+155
-30
lines changed

6 files changed

+155
-30
lines changed

examples/nat/main/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ FROM ${USER_NAME}/nff-go-base
77

88
LABEL RUN docker run -it --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE
99

10+
RUN dnf -y install iputils httpd wget; dnf clean all
11+
1012
WORKDIR /workdir
1113
COPY nat .
1214
COPY config.json .
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"docker-config": {
3+
"request-timeout": 10000000000,
4+
"docker-client-version": "1.24",
5+
"privileged": true,
6+
"map-volumes": [
7+
"/sys/bus/pci/drivers:/sys/bus/pci/drivers",
8+
"/sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages",
9+
"/sys/devices/system/node:/sys/devices/system/node",
10+
"/dev:/dev"
11+
],
12+
"pktgen-port": 22022
13+
},
14+
"tests": [
15+
{
16+
"name": "PingNATFromPrivate",
17+
"test-time": 60000000000,
18+
"test-type": "TestTypeScenario",
19+
"test-apps": [
20+
{
21+
"image-name": "nff-go-nat",
22+
"app-type": "TestAppGo",
23+
"exec-cmd": [
24+
"sh", "-c", "sleep 10; ping -c 5 192.168.14.1 && echo TEST PASSED || echo TEST FAILED"
25+
]
26+
},
27+
{
28+
"image-name": "nff-go-nat",
29+
"app-type": "TestAppGo",
30+
"exec-cmd": [
31+
"./nat", "-config", "config.json"
32+
]
33+
}
34+
]
35+
},
36+
{
37+
"name": "PingNATFromPublic",
38+
"test-time": 60000000000,
39+
"test-type": "TestTypeScenario",
40+
"test-apps": [
41+
{
42+
"image-name": "nff-go-nat",
43+
"app-type": "TestAppGo",
44+
"exec-cmd": [
45+
"sleep", "60"
46+
]
47+
},
48+
{
49+
"image-name": "nff-go-nat",
50+
"app-type": "TestAppGo",
51+
"exec-cmd": [
52+
"./nat", "-config", "config.json"
53+
]
54+
},
55+
{
56+
"image-name": "nff-go-nat",
57+
"app-type": "TestAppGo",
58+
"exec-cmd": [
59+
"sh", "-c", "sleep 10; ping -c 5 192.168.16.1 && echo TEST PASSED || echo TEST FAILED"
60+
]
61+
}
62+
]
63+
},
64+
{
65+
"name": "NATDownloadFile",
66+
"test-time": 60000000000,
67+
"test-type": "TestTypeScenario",
68+
"test-apps": [
69+
{
70+
"image-name": "nff-go-nat",
71+
"app-type": "TestAppGo",
72+
"exec-cmd": [
73+
"sh", "-c", "sleep 10; wget --no-proxy http://192.168.26.2/1m.bin && echo TEST PASSED || echo TEST FAILED"
74+
]
75+
},
76+
{
77+
"image-name": "nff-go-nat",
78+
"app-type": "TestAppGo",
79+
"exec-cmd": [
80+
"./nat", "-config", "config.json"
81+
]
82+
}
83+
]
84+
}
85+
]
86+
}

test/framework/testsuite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (config *TestsuiteConfig) executeOneTest(index int, logdir string,
7575
for {
7676
select {
7777
case r := <-report:
78-
apps[r.AppIndex].Logger.LogInfo(r.AppIndex, "\"", r.msg, "\"")
78+
apps[r.AppIndex].Logger.LogInfo(r.AppIndex, r.msg)
7979
if r.AppStatus == TestReportedFailed || r.AppStatus == TestReportedPassed {
8080
apps[r.AppIndex].Logger.LogDebug("Finished with code", r.AppStatus)
8181

vagrant/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ file and install it with command
1212

1313
sudo dpkg -i vagrant_2.0.1_x86_64.deb
1414

15-
To add a proxyconf plugin to your vagrant installation, run the
16-
following command for normal user
15+
A plugin is required to restart VMs after provisioning:
16+
17+
vagrant plugin install vagrant-reload
18+
19+
If you need to work through http proxy, it is necessary to install
20+
vagrant-proxyconf plugin:
1721

1822
vagrant plugin install vagrant-proxyconf
1923

vagrant/Vagrantfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
# vi: set ft=ruby :
33

44
Vagrant.configure(2) do |config|
5+
unless Vagrant.has_plugin?("vagrant-reload")
6+
raise 'Plugin vagrant-reload is not installed!'
7+
end
8+
59
if Vagrant.has_plugin?("vagrant-proxyconf")
610
config.proxy.http = ENV.fetch('http_proxy', false)
711
config.proxy.https = ENV.fetch('https_proxy', false)
812
end
913

14+
vm_name = ENV.fetch('VM_NAME', "nff-go")
1015
vm_group_size = ENV.fetch('VM_GROUP_SIZE', 2).to_i
1116
vm_total_number = ENV.fetch("VM_TOTAL_NUMBER", 2).to_i
1217
vm_links_number = ENV.fetch("VM_LINKS_NUMBER", 2).to_i
@@ -47,11 +52,12 @@ SHELL
4752

4853
$provision_common = <<SHELL
4954
echo Unpacking Go language into /opt
50-
(cd /opt; sudo sh -c 'curl -L -s https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz | tar zx')
55+
(cd /opt; sudo sh -c 'curl -L -s https://dl.google.com/go/go1.9.4.linux-amd64.tar.gz | tar zx')
5156
mkdir go
5257
chmod +x ~/scripts.sh
5358
. ~/scripts.sh
5459
echo . ~/scripts.sh >> .bashrc
60+
setupdocker
5561
5662
echo Downloading and building NFF-GO
5763
go get -d -v github.com/intel-go/nff-go
@@ -73,20 +79,22 @@ SHELL
7379
# Optional Ubuntu provisioning, use if you want to work in Ubuntu
7480
# environment.
7581
config.vm.provision "shell", privileged: false, run: "never", inline: $provision_ubuntu + $provision_common
82+
# Reboot VM after provisioning
83+
config.vm.provision :reload
7684

7785
# Define six NFF-GO VMs
7886
user = ENV.fetch('USER', "nouser")
7987
(0..vm_total_number - 1).each do |i|
80-
config.vm.define "nff-go-#{i}" do |node|
81-
node.vm.hostname = "nff-go-#{i}"
88+
config.vm.define "#{vm_name}-#{i}" do |node|
89+
node.vm.hostname = "#{vm_name}-#{i}"
8290

8391
# Create inter-VM connections for VMs inside of one VM group
8492
if i % vm_group_size != 0
8593
# Define backward inter-VM virtual network links
8694
(1..vm_links_number).each do |j|
8795
node.vm.network "private_network",
8896
auto_config: false,
89-
virtualbox__intnet: "link-#{user}-#{i}-#{j}"
97+
virtualbox__intnet: "#{vm_name}-link-#{user}-#{i}-#{j}"
9098
end
9199
end
92100

@@ -95,7 +103,7 @@ SHELL
95103
(1..vm_links_number).each do |j|
96104
node.vm.network "private_network",
97105
auto_config: false,
98-
virtualbox__intnet: "link-#{user}-#{i + 1}-#{j}"
106+
virtualbox__intnet: "#{vm_name}-link-#{user}-#{i + 1}-#{j}"
99107
end
100108
end
101109
end

vagrant/scripts.sh

+47-22
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,26 @@ runpktgen ()
3333
rc=$?; if [[ $rc == 0 ]]; then reset; fi
3434
}
3535

36-
# Set up client side machine for NAT example. It initializes two
37-
# network interfaces and sets up default routes to the server
38-
# network. Apache package is installed for apache benchmark program.
36+
# Perform transient NAT client machine configuration. It initializes
37+
# two network interfaces and sets up default routes to the server
38+
# network.
3939
natclient ()
40+
{
41+
sudo ip route add 192.168.16.0/24 via 192.168.14.1 dev $CARD1
42+
sudo ip route add 192.168.26.0/24 via 192.168.24.1 dev $CARD2
43+
}
44+
45+
# Perform one-time configuration needed for NAT client test
46+
# machine. For it apache package is installed for apache benchmark
47+
# program.
48+
setupnatclient ()
4049
{
4150
sudo nmcli c add type ethernet ifname $CARD1 con-name $CARD1 ip4 192.168.14.2/24
4251
sudo nmcli c add type ethernet ifname $CARD2 con-name $CARD2 ip4 192.168.24.2/24
4352
sudo nmcli c up $CARD1
4453
sudo nmcli c up $CARD2
4554

46-
sudo ip route add 192.168.16.0/24 via 192.168.14.1 dev $CARD1
47-
sudo ip route add 192.168.26.0/24 via 192.168.24.1 dev $CARD2
55+
natclient
4856

4957
if [ $DISTRO == Ubuntu ]; then
5058
sudo apt-get install -y apache2
@@ -53,12 +61,12 @@ natclient ()
5361
fi
5462
}
5563

56-
# Set up middle machine for NAT example. It initializes two first
57-
# network interfaces for NFF-GO bindports command and initializes
58-
# second interface pair for use with Linux NAT. In this setup enp0s16
59-
# is connected to server (public network) and enp0s9 is connected to
60-
# client (private network).
61-
natsetup ()
64+
# Perform transient configuration for NAT middle machine. It
65+
# initializes two first network interfaces for NFF-GO bindports
66+
# command and initializes second interface pair for use with Linux
67+
# NAT. In this setup eth4(enp0s16) is connected to server (public
68+
# network) and eth2(enp0s9) is connected to client (private network).
69+
natmiddle ()
6270
{
6371
export NFF_GO_CARDS="00:08.0 00:0a.0"
6472
if [ $DISTRO == Ubuntu ]; then
@@ -68,30 +76,43 @@ natsetup ()
6876
export CARD1=eth2
6977
export CARD2=eth4
7078
fi
71-
sudo nmcli c add type ethernet ifname $CARD1 con-name $CARD1 ip4 192.168.24.1/24
72-
sudo nmcli c add type ethernet ifname $CARD2 con-name $CARD2 ip4 192.168.26.1/24
73-
sudo nmcli c up $CARD1
74-
sudo nmcli c up $CARD2
79+
80+
bindports
7581

7682
sudo sysctl -w net.ipv4.ip_forward=1
7783

7884
if [ $DISTRO == Ubuntu ]; then
7985
sudo iptables -t nat -A POSTROUTING -o $CARD2 -j MASQUERADE
8086
sudo iptables -A FORWARD -i $CARD2 -o $CARD1 -m state --state RELATED,ESTABLISHED -j ACCEPT
8187
sudo iptables -A FORWARD -i $CARD1 -o $CARD2 -j ACCEPT
82-
elif [ $DISTRO == Fedora ]; then
83-
sudo firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -o $CARD2 -j MASQUERADE
84-
sudo firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i $CARD2 -o $CARD1 -m state --state RELATED,ESTABLISHED -j ACCEPT
85-
sudo firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i $CARD1 -o $CARD2 -j ACCEPT
88+
fi
89+
}
90+
91+
# Perform one-time configuration needed for NAT middle machine. On
92+
# Fedora we use firewall daemon to permanently record IP forwarding
93+
# rules.
94+
setupnatmiddle ()
95+
{
96+
natmiddle
97+
98+
sudo nmcli c add type ethernet ifname $CARD1 con-name $CARD1 ip4 192.168.24.1/24
99+
sudo nmcli c add type ethernet ifname $CARD2 con-name $CARD2 ip4 192.168.26.1/24
100+
sudo nmcli c up $CARD1
101+
sudo nmcli c up $CARD2
102+
103+
if [ $DISTRO == Fedora ]; then
86104
sudo firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o $CARD2 -j MASQUERADE
87105
sudo firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i $CARD2 -o $CARD1 -m state --state RELATED,ESTABLISHED -j ACCEPT
88106
sudo firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i $CARD1 -o $CARD2 -j ACCEPT
107+
sudo firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -o $CARD2 -j MASQUERADE
108+
sudo firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i $CARD2 -o $CARD1 -m state --state RELATED,ESTABLISHED -j ACCEPT
109+
sudo firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i $CARD1 -o $CARD2 -j ACCEPT
89110
fi
90111
}
91112

92-
# Set up server side machine for NAT example. It initializes two
93-
# network interfaces and installs Apache web server.
94-
natserver ()
113+
# Perform one-time configuration needed for NAT server side
114+
# machine. It installs Apache web server.
115+
setupnatserver ()
95116
{
96117
sudo nmcli c add type ethernet ifname $CARD1 con-name $CARD1 ip4 192.168.16.2/24
97118
sudo nmcli c add type ethernet ifname $CARD2 con-name $CARD2 ip4 192.168.26.2/24
@@ -109,6 +130,10 @@ natserver ()
109130
sudo systemctl enable httpd
110131
sudo systemctl start httpd
111132
fi
133+
134+
sudo dd if=/dev/zero of=/var/www/html/10k.bin bs=1 count=10240
135+
sudo dd if=/dev/zero of=/var/www/html/100k.bin bs=1 count=102400
136+
sudo dd if=/dev/zero of=/var/www/html/1m.bin bs=1 count=1048576
112137
}
113138

114139
# Set up docker daemon, this is needed for automated testing.

0 commit comments

Comments
 (0)