Method: ContainerManager#check

Defined in:
lib/wf_node_api/container_manager.rb

#checkObject

Checks the installation with a simple test procedure

Raises:

  • (StandardError)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/wf_node_api/container_manager.rb', line 31

def check
  name = (0...8).map { (65 + rand(26)).chr }.join
  puts "==> Random name for the container: #{name}"

  # containers should return an array
  puts "==> Listing containers"
  res = containers()
  #puts res.inspect

  raise 'containers() failed' unless res.is_a?(Array)
  puts "==> PASS"

  # container should not work
  puts "==> Getting container info on non-existant container (should not work)"

  begin
    res = container(name)
    raise 'container() failed'
  rescue => e
    puts "==> PASS"
  end

  # delete should not work
  puts "==> Delete non-existing container (should not work)"

  begin
    res = delete(name)
    raise 'delete() failed'
  rescue => e
    puts "==> PASS"
  end

  # start should not work
  puts "==> Starting non-existing container (should not work)"

  begin
    res = start(name)
    raise 'start() failed'
  rescue => e
    puts "==> PASS"
  end

  # stop should not work
  puts "==> Stopping non-existing container (should not work)"

  begin
    res = stop(name)
    raise 'stop() failed'
  rescue => e
    puts "==> PASS"
  end

  # kill should not work
  puts "==> Killing non-existing container (should not work)"

  begin
    res = kill(name)
    raise 'kill() failed'
  rescue => e
    puts "==> PASS"
  end

  # create should work
  puts "==> Create container"
  create_container(name, '1.2.3.4', 1, 64, 1)
  puts "==> PASS"

  # start should work
  puts "==> Starting container"
  start(name)
  puts "==> PASS"

  # stop should work
  puts "==> Stopping container"
  stop(name)
  puts "==> PASS"

  # kill should not work
  puts "==> Killing stopped container (should not work)"

  begin
    res = kill(name)
    raise 'kill() failed'
  rescue => e
    puts "==> PASS"
  end

  # stop should not work
  puts "==> Stopping stopped container (should not work)"

  begin
    res = stop(name)
    raise 'stop() failed'
  rescue => e
    puts "==> PASS"
  end

  # start should work
  puts "==> Starting container"
  start(name)
  puts "==> PASS"

  # kill should work
  puts "==> Killing container"
  kill(name)
  puts "==> PASS"

  # delete should work
  puts "==> Deleting container"
  delete(name)
  puts "==> PASS"
end