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'
d033e2
d033e2
export eth_int=$(ip addr|grep -B 1 "link/ether"|head -n 1|awk '{print $2}'|tr -d ':')
d033e2
d033e2
# create VLAN-IF 10 on ethernet device
d033e2
ip link add dev ${eth_int}.10 link ${eth_int} type vlan id 10
d033e2
ip addr list | grep -q ${eth_int}.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
d033e2
ip address add 172.16.30.1/32 dev ${eth_int}.10
Christoph Galuschka 8c8b64
ip addr list | grep -q 172.16.30.1
Christoph Galuschka 8c8b64
if [ $? == 1 ]
Christoph Galuschka 8c8b64
  then
d033e2
  t_Log "IP address assignment on ${eth_int}.10 failed"
Christoph Galuschka 8c8b64
  ret_val=1
Christoph Galuschka 8c8b64
else
d033e2
  t_Log "IP address successfully assigned on ${eth_int}.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
d033e2
  t_Log "pinging on ${eth_int}.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
d033e2
# delete VLAN-IF 10 on ethernet interface
d033e2
ip link delete ${eth_int}.10
d033e2
ip addr list | grep -q ${eth_int}.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