Revision c6c217d4 src/oca/ruby/test/HostPool_spec.rb

View differences:

src/oca/ruby/test/HostPool_spec.rb
23 23
                host.class.to_s.should eql("OpenNebula::Host")
24 24
                if host.id == 0
25 25
                    host.name.should eql('dummyhost')
26
                    host['STATE'].should eql('2')
27
                    host['IM_MAD'].should eql('im_dummy')
28
                    host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
29
                    host['HOST_SHARE/CPU_USAGE'].should eql('300')
30
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
31
                    host['HOST_SHARE/RUNNING_VMS'].should eql('3')
26 32
                elsif host.id == 1
27 33
                    host.name.should eql('thost')
34
                    host['STATE'].should eql('2')
35
                    host['IM_MAD'].should eql('im_dummy')
36
                    host['HOST_SHARE/MEM_USAGE'].should eql('0')
37
                    host['HOST_SHARE/CPU_USAGE'].should eql('0')
38
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
39
                    host['HOST_SHARE/RUNNING_VMS'].should eql('0')
28 40
                end
29 41
            }
30 42
        end
31
        
32
        it "should get a hash representation of the HOST_POOL" do
33
            host_hash = @host_pool.to_hash
34
            host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
35
            host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
36
            host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
37
            host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
38
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
39
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
40
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
41
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
42
            host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
43
            host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
44
            host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
45
            host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
46
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
47
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
48
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
49
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
50
        end
51 43
    end
52 44
    
53 45
    describe "Host using REXML" do
......
68 60
                host.class.to_s.should eql("OpenNebula::Host")
69 61
                if host.id == 0
70 62
                    host.name.should eql('dummyhost')
63
                    host['STATE'].should eql('2')
64
                    host['IM_MAD'].should eql('im_dummy')
65
                    host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
66
                    host['HOST_SHARE/CPU_USAGE'].should eql('300')
67
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
68
                    host['HOST_SHARE/RUNNING_VMS'].should eql('3')
71 69
                elsif host.id == 1
72 70
                    host.name.should eql('thost')
71
                    host['STATE'].should eql('2')
72
                    host['IM_MAD'].should eql('im_dummy')
73
                    host['HOST_SHARE/MEM_USAGE'].should eql('0')
74
                    host['HOST_SHARE/CPU_USAGE'].should eql('0')
75
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
76
                    host['HOST_SHARE/RUNNING_VMS'].should eql('0')
73 77
                end
74 78
            }
75 79
        end
76
        
77
        it "should get a hash representation of the HOST_POOL" do
78
            host_hash = @host_pool.to_hash
79
            host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
80
            host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
81
            host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
82
            host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
83
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
84
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
85
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
86
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
87
            host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
88
            host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
89
            host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
90
            host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
91
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
92
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
93
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
94
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
95
        end
96 80
    end
97 81
end

Also available in: Unified diff