Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only show nodes if it's positive #4074

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
<span class="card-text"> (<%= session.job_id %>)</span>
<div class="float-end">
<%- if session.starting? || session.running? -%>
<%- if num_nodes.positive? -%>
<span class="badge <%= badge_class %> rounded-pill"><%= pluralize(num_nodes, "node") %></span>
<span class="card-text"> | </span>
<%- end -%>
<%- if num_cores.positive? -%>
<span class="badge <%= badge_class %> rounded-pill"><%= pluralize(num_cores, "core") %></span>
<span class="card-text"> | </span>
<%- end -%>
<%- end -%>
<%= status(session) %>
<%- if session.completed? && !session.app.preset? -%>
<span class="card-text"> | </span>
Expand Down
67 changes: 63 additions & 4 deletions apps/dashboard/test/system/batch_connect_sessions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def create_test_file(dir, token: 'sys/bc_paraview', title: 'Paraview')
File.write("#{dir}/#{test_bc_id}", test_data(token: token, title: title).to_json)
end

def stub_scheduler(state)
info = OodCore::Job::Info.new(id: test_job_id, status: state.to_sym)
def stub_scheduler(state, cores: 1, nodes: 1)
info = OodCore::Job::Info.new(
id: test_job_id, status: state.to_sym, procs: cores.to_i,
allocated_nodes: Array.new(nodes.to_i, { name: 'foo', features: [] })
)
OodCore::Job::Adapters::Slurm.any_instance.stubs(:info).returns(info)
end

Expand Down Expand Up @@ -103,7 +106,7 @@ def stub_scheduler(state)
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Jupyter (#{test_job_id})\n0 nodes | 0 cores | Starting", header_text)
assert_equal("Jupyter (#{test_job_id})\n1 node | 1 core | Starting", header_text)
end
end

Expand All @@ -117,10 +120,66 @@ def stub_scheduler(state)
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Paraview (#{test_job_id})\n0 nodes | 0 cores | Starting", header_text)
assert_equal("Paraview (#{test_job_id})\n1 node | 1 core | Starting", header_text)

info_text = card.find("#info_test_div").text
assert_equal('This is a test message for an info view.', info_text)
end
end

test 'running sessions with 0 nodes and cores' do
Dir.mktmpdir do |dir|
create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter')
stub_scheduler(:running, nodes: 0, cores: 0)
visit(batch_connect_sessions_path)

card = find("#id_#{test_bc_id}")
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Jupyter (#{test_job_id})\nStarting", header_text)
end
end

test 'running sessions with 0 nodes and 1 core' do
Dir.mktmpdir do |dir|
create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter')
stub_scheduler(:running, nodes: 0, cores: 1)
visit(batch_connect_sessions_path)

card = find("#id_#{test_bc_id}")
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Jupyter (#{test_job_id})\n1 core | Starting", header_text)
end
end

test 'running sessions with 1 nodes and 0 cores' do
Dir.mktmpdir do |dir|
create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter')
stub_scheduler(:running, nodes: 0, cores: 1)
visit(batch_connect_sessions_path)

card = find("#id_#{test_bc_id}")
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Jupyter (#{test_job_id})\n1 core | Starting", header_text)
end
end

test 'running sessions correctly pluralize nodes and cores' do
Dir.mktmpdir do |dir|
create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter')
stub_scheduler(:running, nodes: 2, cores: 2)
visit(batch_connect_sessions_path)

card = find("#id_#{test_bc_id}")
assert_not_nil(card)

header_text = card.find('.h5').text
assert_equal("Jupyter (#{test_job_id})\n2 nodes | 2 cores | Starting", header_text)
end
end
end
Loading