Files
ubicloud/spec/model/github_installation_spec.rb
Benjamin Satzger 9d520f9f23 Change total_active_runner_cores to count cores
Before this commit, total_active_runner_cores returned the number active
runner vCPUs. This commit changes the logic to return the number of
active cores.
2024-07-05 12:25:01 +02:00

35 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require_relative "spec_helper"
RSpec.describe GithubInstallation do
subject(:installation) {
project = Project.create_with_id(name: "default").tap { _1.associate_with_project(_1) }
described_class.create_with_id(installation_id: 123, project_id: project.id, name: "test-user", type: "User")
}
it "returns sum of used vm cores" do
vms = [2, 4, 8].map { create_vm(cores: _1) }
# let's not create runner for the last vm
vms[..1].each do |vm|
gr = GithubRunner.create_with_id(installation_id: installation.id, vm_id: vm.id, repository_name: "test-repo", label: "ubicloud-standard-#{vm.cores}")
Strand.create(prog: "Github::RunnerNexus", label: "allocate_vm") { _1.id = gr.id }
end
expect(installation.total_active_runner_cores).to eq(3)
end
it "returns sum of used vm cores for arm64" do
vms = [2, 4].map { create_vm(cores: _1, arch: "arm64") }
vms.each do |vm|
gr = GithubRunner.create_with_id(installation_id: installation.id, vm_id: vm.id, repository_name: "test-repo", label: "ubicloud-standard-#{vm.cores}-arm")
Strand.create(prog: "Github::RunnerNexus", label: "allocate_vm") { _1.id = gr.id }
end
expect(installation.total_active_runner_cores).to eq(6)
end
end