3 class NodeTest < ActiveSupport::TestCase
4 def ping_node(node_name, ping_data)
5 set_user_from_auth :admin
6 node = nodes(node_name)
7 node.ping({ping_secret: node.info['ping_secret'],
8 ip: node.ip_address}.merge(ping_data))
12 test "pinging a node can add and update stats" do
13 node = ping_node(:idle, {total_cpu_cores: '12', total_ram_mb: '512'})
14 assert_equal(12, node.properties['total_cpu_cores'])
15 assert_equal(512, node.properties['total_ram_mb'])
18 test "stats disappear if not in a ping" do
19 node = ping_node(:idle, {total_ram_mb: '256'})
20 refute_includes(node.properties, 'total_cpu_cores')
21 assert_equal(256, node.properties['total_ram_mb'])
24 test "worker state is down for node with no slot" do
25 node = nodes(:was_idle_now_down)
26 assert_nil node.slot_number, "fixture is not what I expected"
27 assert_equal 'down', node.crunch_worker_state, "wrong worker state"