mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
feature #476: new tester for the networking hooks
This commit is contained in:
parent
4f2839dda3
commit
8681584eb1
@ -99,7 +99,7 @@ end
|
||||
|
||||
|
||||
class OpenNebulaVLAN
|
||||
attr_reader :vm_info, :hypervisor
|
||||
attr_reader :vm_info, :hypervisor, :nics
|
||||
|
||||
def initialize(vm_tpl, hypervisor=nil)
|
||||
@vm_root = REXML::Document.new(vm_tpl).root
|
||||
@ -212,7 +212,7 @@ class EbtablesVLAN < OpenNebulaVLAN
|
||||
end
|
||||
|
||||
def ebtables(rule)
|
||||
system "#{CONF[:ebtables]} -A #{rule}"
|
||||
system("#{CONF[:ebtables]} -A #{rule}")
|
||||
end
|
||||
|
||||
def activate
|
||||
|
82
share/hooks/spec/OpenNebulaVLAN_spec.rb
Normal file
82
share/hooks/spec/OpenNebulaVLAN_spec.rb
Normal file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'rspec'
|
||||
require 'open3'
|
||||
require 'pp'
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../OpenNebulaVLAN')
|
||||
|
||||
OUTPUT = Hash.new
|
||||
Dir[File.dirname(__FILE__) + "/output/**"].each do |f|
|
||||
key = File.basename(f).to_sym
|
||||
OUTPUT[key] = File.read(f)
|
||||
end
|
||||
|
||||
$collector = Hash.new
|
||||
|
||||
def execute_cmd(cmd)
|
||||
if cmd =~ /virsh.*dumpxml/
|
||||
OUTPUT[:virsh_dumpxml]
|
||||
else
|
||||
Open3.popen3(cmd){|stdin, stdout, stderr| stdout.read}
|
||||
end
|
||||
end
|
||||
|
||||
def `(cmd)
|
||||
$collector[:backtick] << cmd
|
||||
execute_cmd(cmd)
|
||||
end
|
||||
|
||||
def system(cmd)
|
||||
$collector[:system] << cmd
|
||||
#Kernel::system(cmd)
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before(:all) do
|
||||
$collector[:system] = Array.new
|
||||
$collector[:backtick] = Array.new
|
||||
end
|
||||
end
|
||||
|
||||
describe 'networking' do
|
||||
it "get all nics in kvm" do
|
||||
onevlan = OpenNebulaVLAN.new(OUTPUT[:onevm_show],"kvm")
|
||||
nics_expected = [{:bridge=>"br0",
|
||||
:ip=>"172.16.0.100",
|
||||
:mac=>"02:00:ac:10:00:64",
|
||||
:network=>"Small network",
|
||||
:network_id=>"0",
|
||||
:tap=>"vnet0"},
|
||||
{:bridge=>"br1",
|
||||
:ip=>"10.1.1.1",
|
||||
:mac=>"02:00:0a:01:01:01",
|
||||
:network=>"r1",
|
||||
:network_id=>"1",
|
||||
:tap=>"vnet1"},
|
||||
{:bridge=>"br2",
|
||||
:ip=>"10.1.2.1",
|
||||
:mac=>"02:00:0a:01:02:01",
|
||||
:network=>"r2",
|
||||
:network_id=>"2",
|
||||
:tap=>"vnet2"}]
|
||||
onevlan.nics.should == nics_expected
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ebtables' do
|
||||
it "generate ebtable rules in kvm" do
|
||||
onevlan = EbtablesVLAN.new(OUTPUT[:onevm_show],"kvm")
|
||||
onevlan.activate
|
||||
ebtables_cmds = [
|
||||
" -A FORWARD -s ! 02:00:ac:10:00:00/ff:ff:ff:ff:ff:00 -o vnet0 -j DROP",
|
||||
" -A FORWARD -s ! 02:00:ac:10:00:64 -i vnet0 -j DROP",
|
||||
" -A FORWARD -s ! 02:00:0a:01:01:00/ff:ff:ff:ff:ff:00 -o vnet1 -j DROP",
|
||||
" -A FORWARD -s ! 02:00:0a:01:01:01 -i vnet1 -j DROP",
|
||||
" -A FORWARD -s ! 02:00:0a:01:02:00/ff:ff:ff:ff:ff:00 -o vnet2 -j DROP",
|
||||
" -A FORWARD -s ! 02:00:0a:01:02:01 -i vnet2 -j DROP"]
|
||||
|
||||
$collector[:system].should == ebtables_cmds
|
||||
end
|
||||
end
|
107
share/hooks/spec/output/kvm_lsmod
Normal file
107
share/hooks/spec/output/kvm_lsmod
Normal file
@ -0,0 +1,107 @@
|
||||
Module Size Used by
|
||||
xts 2421 8
|
||||
gf128mul 5690 1 xts
|
||||
dm_crypt 15457 1
|
||||
dm_mod 64396 3 dm_crypt
|
||||
kvm_intel 49771 6
|
||||
kvm 314766 1 kvm_intel
|
||||
ip6table_filter 1420 0
|
||||
ip6_tables 17584 1 ip6table_filter
|
||||
tun 15525 12
|
||||
ipt_REJECT 2337 2
|
||||
xt_CHECKSUM 1223 1
|
||||
iptable_mangle 1576 1
|
||||
xt_tcpudp 2495 5
|
||||
nls_cp437 5913 1
|
||||
vfat 10143 1
|
||||
fat 47937 1 vfat
|
||||
ipt_MASQUERADE 1666 4
|
||||
bridge 70237 0
|
||||
stp 1600 1 bridge
|
||||
llc 3521 2 bridge,stp
|
||||
ipv6 277133 29 bridge
|
||||
cryptd 7661 0
|
||||
aes_x86_64 7436 17
|
||||
aes_generic 26066 1 aes_x86_64
|
||||
hid_logitech 12032 0
|
||||
ff_memless 4635 1 hid_logitech
|
||||
xt_state 1255 2
|
||||
iptable_filter 1480 1
|
||||
iptable_nat 3920 1
|
||||
nf_nat 14980 2 ipt_MASQUERADE,iptable_nat
|
||||
nf_conntrack_ipv4 11177 5 iptable_nat,nf_nat
|
||||
nf_conntrack 56218 5 ipt_MASQUERADE,xt_state,iptable_nat,nf_nat,nf_conntrack_ipv4
|
||||
nf_defrag_ipv4 1363 1 nf_conntrack_ipv4
|
||||
ip_tables 16295 3 iptable_mangle,iptable_filter,iptable_nat
|
||||
x_tables 16643 11 ip6table_filter,ip6_tables,ipt_REJECT,xt_CHECKSUM,iptable_mangle,xt_tcpudp,ipt_MASQUERADE,xt_state,iptable_filter,iptable_nat,ip_tables
|
||||
snd_hda_codec_hdmi 22282 4
|
||||
usbhid 33814 1 hid_logitech
|
||||
hid 76802 2 hid_logitech,usbhid
|
||||
uvcvideo 60799 0
|
||||
videodev 65175 1 uvcvideo
|
||||
btusb 11153 0
|
||||
v4l2_compat_ioctl32 6716 1 videodev
|
||||
bluetooth 55377 1 btusb
|
||||
arc4 1402 2
|
||||
ecb 2033 2
|
||||
nvidia 10481030 45
|
||||
joydev 9767 0
|
||||
snd_hda_codec_realtek 294053 1
|
||||
fuse 64542 3
|
||||
snd_hda_intel 21738 4
|
||||
snd_hda_codec 73739 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel
|
||||
iwlagn 385759 0
|
||||
vboxnetflt 19108 0
|
||||
snd_hwdep 6134 1 snd_hda_codec
|
||||
snd_pcm 71032 4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
|
||||
snd_timer 18992 2 snd_pcm
|
||||
mmc_block 9580 2
|
||||
snd 55132 13 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
|
||||
iwlcore 103238 1 iwlagn
|
||||
soundcore 5986 1 snd
|
||||
firewire_ohci 28105 0
|
||||
mac80211 202222 2 iwlagn,iwlcore
|
||||
snd_page_alloc 7017 2 snd_hda_intel,snd_pcm
|
||||
sony_laptop 25073 0
|
||||
i2c_i801 7987 0
|
||||
firewire_core 47790 1 firewire_ohci
|
||||
vboxdrv 1760003 1 vboxnetflt
|
||||
crc_itu_t 1321 1 firewire_core
|
||||
ehci_hcd 39113 0
|
||||
cfg80211 141484 3 iwlagn,iwlcore,mac80211
|
||||
usbcore 134923 5 usbhid,uvcvideo,btusb,ehci_hcd
|
||||
wmi 8083 0
|
||||
rfkill 14810 3 bluetooth,sony_laptop,cfg80211
|
||||
i2c_core 18740 3 videodev,nvidia,i2c_i801
|
||||
thermal 7631 0
|
||||
atl1c 31559 0
|
||||
ac 3193 0
|
||||
sg 24917 0
|
||||
button 4794 0
|
||||
battery 10410 0
|
||||
video 10996 0
|
||||
serio_raw 4222 0
|
||||
processor 23608 0
|
||||
sdhci_pci 8202 0
|
||||
iTCO_wdt 11053 0
|
||||
intel_agp 10480 0
|
||||
iTCO_vendor_support 1857 1 iTCO_wdt
|
||||
sdhci 17061 1 sdhci_pci
|
||||
intel_gtt 13943 1 intel_agp
|
||||
pcspkr 1843 0
|
||||
mmc_core 63886 2 mmc_block,sdhci
|
||||
psmouse 52944 0
|
||||
intel_ips 10885 0
|
||||
evdev 9178 24
|
||||
loop 17358 2
|
||||
ext4 332976 4
|
||||
mbcache 5649 1 ext4
|
||||
jbd2 69632 1 ext4
|
||||
crc16 1321 1 ext4
|
||||
sr_mod 14247 0
|
||||
cdrom 35689 1 sr_mod
|
||||
sd_mod 26276 5
|
||||
ahci 20441 4
|
||||
libahci 17966 1 ahci
|
||||
libata 167694 2 ahci,libahci
|
||||
scsi_mod 123282 4 sg,sr_mod,sd_mod,libata
|
1
share/hooks/spec/output/kvm_uname_a
Normal file
1
share/hooks/spec/output/kvm_uname_a
Normal file
@ -0,0 +1 @@
|
||||
Linux rama 2.6.38-ARCH #1 SMP PREEMPT Wed Mar 30 08:47:36 CEST 2011 x86_64 Intel(R) Core(TM) i5 CPU M 450 @ 2.40GHz GenuineIntel GNU/Linux
|
55
share/hooks/spec/output/virsh_dumpxml
Normal file
55
share/hooks/spec/output/virsh_dumpxml
Normal file
@ -0,0 +1,55 @@
|
||||
<domain type='kvm' id='3'>
|
||||
<name>one-2</name>
|
||||
<uuid>bea46e50-c328-7299-afbd-b5ba4c74b651</uuid>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc-0.14'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/kvm</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='/home/jmelis/work/git/one/one/var//2/images/disk.0'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
<alias name='scsi0-0-0'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='scsi' index='0'>
|
||||
<alias name='scsi0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
||||
</controller>
|
||||
<interface type='bridge'>
|
||||
<mac address='02:00:ac:10:00:64'/>
|
||||
<source bridge='br0'/>
|
||||
<target dev='vnet0'/>
|
||||
<alias name='net0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='02:00:0a:01:01:01'/>
|
||||
<source bridge='br1'/>
|
||||
<target dev='vnet1'/>
|
||||
<alias name='net1'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='02:00:0a:01:02:01'/>
|
||||
<source bridge='br2'/>
|
||||
<target dev='vnet2'/>
|
||||
<alias name='net2'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||
</interface>
|
||||
<memballoon model='virtio'>
|
||||
<alias name='balloon0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
|
||||
</memballoon>
|
||||
</devices>
|
||||
</domain>
|
||||
|
Loading…
Reference in New Issue
Block a user