Files
ubicloud/spec/model/vm_storage_volume_spec.rb
Burak Yucesoy 92214f27e8 Add support for multiple disk devices for Postgres
Bigger AWS instances comes with multiple smaller disk devices instead of one
big disk. We need to combine these devices with RAID0 configuration to
provide a single big disk to Postgres.
2025-07-07 10:52:33 +03:00

72 lines
2.8 KiB
Ruby

# frozen_string_literal: true
require_relative "spec_helper"
RSpec.describe VmStorageVolume do
it "can render a device_path" do
vm = Vm.new(location: Location[Location::HETZNER_FSN1_ID]).tap { it.id = "eb3dbcb3-2c90-8b74-8fb4-d62a244d7ae5" }
expect(described_class.new(disk_index: 7, vm: vm).device_path).to eq("/dev/disk/by-id/virtio-vmxcyvsc_7")
end
it "can render a device_path for aws" do
prj = Project.create_with_id(name: "test-project")
vm = Vm.new(location: Location.create_with_id(name: "us-west-2", provider: "aws", project_id: prj.id, display_name: "aws-us-west-2", ui_name: "AWS US East 1", visible: true)).tap { it.id = "eb3dbcb3-2c90-8b74-8fb4-d62a244d7ae5" }
expect(described_class.new(disk_index: 2, vm: vm).device_path).to eq("/dev/nvme2n1")
end
it "returns correct spdk version if exists associated installation" do
si = SpdkInstallation.new(version: "some-version")
v = described_class.new(disk_index: 7)
allow(v).to receive(:spdk_installation).and_return(si)
expect(v.spdk_version).to eq("some-version")
end
it "returns nil spdk version if no associated installation" do
v = described_class.new(disk_index: 7)
allow(v).to receive(:spdk_installation).and_return(nil)
expect(v.spdk_version).to be_nil
end
it "returns correct vhost_block_backend version if exists associated installation" do
vbb = VhostBlockBackend.new(version: "some-vhost-version")
v = described_class.new(disk_index: 7)
allow(v).to receive(:vhost_block_backend).and_return(vbb)
expect(v.vhost_block_backend_version).to eq("some-vhost-version")
end
it "returns nil vhost_block_backend version if no associated installation" do
v = described_class.new(disk_index: 7)
allow(v).to receive(:vhost_block_backend).and_return(nil)
expect(v.vhost_block_backend_version).to be_nil
end
describe "#num_queues" do
it "returns 1 for SPDK volumes" do
v = described_class.new(disk_index: 7)
allow(v).to receive(:vhost_block_backend).and_return(nil)
expect(v.num_queues).to eq(1)
end
it "returns max of vm.vcpus / 2 and 1 for vhost_block_backend volumes" do
vm = Vm.new(vcpus: 4).tap { it.id = "eb3dbcb3-2c90-8b74-8fb4-d62a244d7ae5" }
v = described_class.new(disk_index: 7, vm: vm)
allow(v).to receive(:vhost_block_backend).and_return(VhostBlockBackend.new)
expect(v.num_queues).to eq(2)
end
end
describe "#queue_size" do
it "returns 256 for SPDK volumes" do
v = described_class.new(disk_index: 7)
allow(v).to receive(:vhost_block_backend).and_return(nil)
expect(v.queue_size).to eq(256)
end
it "returns 64 for vhost_block_backend volumes" do
v = described_class.new(disk_index: 7)
allow(v).to receive(:vhost_block_backend).and_return(VhostBlockBackend.new)
expect(v.queue_size).to eq(64)
end
end
end