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

Ensure that the runner can log duration even without a vm #1540

Merged
merged 1 commit into from
May 7, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions model/github_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ def display_state
end

def log_duration(message, duration)
values = {ubid: ubid, label: label, repository_name: repository_name, duration: duration, vm_ubid: vm.ubid, arch: vm.arch, cores: vm.cores}
values[:vm_host_ubid] = vm.vm_host.ubid if vm.vm_host
values[:vm_pool_ubid] = VmPool[vm.pool_id].ubid if vm.pool_id
values = {ubid: ubid, label: label, repository_name: repository_name, duration: duration}
if vm
values.merge!(vm_ubid: vm.ubid, arch: vm.arch, cores: vm.cores)
values[:vm_host_ubid] = vm.vm_host.ubid if vm.vm_host
enescakir marked this conversation as resolved.
Show resolved Hide resolved
values[:vm_pool_ubid] = VmPool[vm.pool_id].ubid if vm.pool_id
end
Clog.emit(message) { {message => values} }
end

Expand Down
6 changes: 6 additions & 0 deletions spec/model/github_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
github_runner.log_duration("runner_tested", 10)
end

it "can log duration without a vm" do
expect(github_runner).to receive(:vm).and_return(nil)
expect(Clog).to receive(:emit).with("runner_tested").and_call_original
github_runner.log_duration("runner_tested", 10)
end

it "provisions a spare runner" do
expect(Prog::Vm::GithubRunner).to receive(:assemble).with(github_runner.installation, repository_name: github_runner.repository_name, label: github_runner.label)
.and_return(instance_double(Strand, subject: instance_double(described_class)))
Expand Down