Blame tests/p_network/networking_vlan_test.sh

Christoph Galuschka bd5ac8
#!/bin/sh
Christoph Galuschka bd5ac8
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka bd5ac8
Christoph Galuschka 8c8b64
t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF using IP command test (not on C5)"
Christoph Galuschka bd5ac8
ret_val=0
Christoph Galuschka bd5ac8
Christoph Galuschka 8c8b64
if [ $centos_ver -lt 6 ]
Christoph Galuschka 8c8b64
then
Christoph Galuschka 8c8b64
  t_Log ' This is a C5 system, skipping test'
Christoph Galuschka 8c8b64
  exit 0
Christoph Galuschka 8c8b64
fi  
Christoph Galuschka 8c8b64
Christoph Galuschka 8c8b64
t_Log 'This is no C5-system, commencing test'
Christoph Galuschka 8c8b64
# create VLAN-IF 10 on eth0
Christoph Galuschka 8c8b64
ip link add dev eth0.10 link eth0 type vlan id 10
Christoph Galuschka 8c8b64
ip addr list | grep -q eth0.10
Christoph Galuschka 8c8b64
if [ $? == 1 ]
Christoph Galuschka bd5ac8
  then
Christoph Galuschka 8c8b64
  t_Log "VLAN-IF creation failed"
Christoph Galuschka 8c8b64
  ret_val=1
Christoph Galuschka 8c8b64
else
Christoph Galuschka 8c8b64
  t_Log "VLAN-IF successfully created"
Christoph Galuschka 8c8b64
fi
Christoph Galuschka bd5ac8
Christoph Galuschka 8c8b64
#assign IP address on VLAN-IF
Christoph Galuschka 8c8b64
ip address add 172.16.30.1/32 dev eth0.10
Christoph Galuschka 8c8b64
ip addr list | grep -q 172.16.30.1
Christoph Galuschka 8c8b64
if [ $? == 1 ]
Christoph Galuschka 8c8b64
  then
Christoph Galuschka 8c8b64
  t_Log "IP address assignment on eth0.10 failed"
Christoph Galuschka 8c8b64
  ret_val=1
Christoph Galuschka 8c8b64
else
Christoph Galuschka 8c8b64
  t_Log "IP address successfully assigned on eth1.10"
Christoph Galuschka 8c8b64
fi
Christoph Galuschka bd5ac8
Christoph Galuschka 8c8b64
#testing address with ping
Christoph Galuschka 8c8b64
ping -c 4 -q 172.16.30.1 | grep -q '4 received'
Christoph Galuschka 8c8b64
if [ $? == 1 ]
Christoph Galuschka 8c8b64
  then
Christoph Galuschka 8c8b64
  t_Log "pinging on eth0.10 failed"
Christoph Galuschka 8c8b64
  ret_val=1
Christoph Galuschka 8c8b64
else
Christoph Galuschka 8c8b64
  t_Log "local ping on VLAN IF worked"
Christoph Galuschka 8c8b64
fi
Christoph Galuschka bd5ac8
Christoph Galuschka 8c8b64
# delete VLAN-IF 10 on eth0
Christoph Galuschka 8c8b64
ip link delete eth0.10
Christoph Galuschka 8c8b64
ip addr list | grep -q eth0.10
Christoph Galuschka 8c8b64
if [ $? == 0 ]
Christoph Galuschka 8c8b64
  then
Christoph Galuschka 8c8b64
  t_Log "Removing VLAN IF failed"
Christoph Galuschka 8c8b64
  ret_val=1
Christoph Galuschka bd5ac8
else
Christoph Galuschka 8c8b64
  t_Log "Removing of VLAN IF worked"
Christoph Galuschka bd5ac8
fi
Christoph Galuschka bd5ac8
Christoph Galuschka bd5ac8
t_CheckExitStatus $ret_val