Files
ubicloud/spec/model/minio/minio_cluster_spec.rb
Jeremy Evans feb1c97ff5 Mark project_id columns newly added to tables as NOT NULL
These columns are now populated and required during insert.
This causes a large amount of fallout in the specs, as there
were many places that inserted rows without having a related
project.

No changes outside the specs except for
ApiKey#create_personal_access_token, which now requires a
project keyword argument, since the method would fail without
it now (the was previously optional).
2025-01-17 12:47:51 -08:00

63 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe MinioCluster do
subject(:mc) {
mc = described_class.create_with_id(
location: "hetzner-fsn1",
name: "minio-cluster-name",
admin_user: "minio-admin",
admin_password: "dummy-password",
root_cert_1: "root_cert_1",
root_cert_2: "root_cert_2",
project_id: Project.create(name: "test").id
)
mp = MinioPool.create_with_id(
cluster_id: mc.id,
start_index: 0,
server_count: 1,
drive_count: 1,
storage_size_gib: 100,
vm_size: "standard-2"
)
MinioServer.create_with_id(
minio_pool_id: mp.id,
vm_id: create_vm.id,
index: 0
)
mc
}
it "generates /etc/hosts entries properly when there are multiple pool" do
server = mc.servers.first
expect(mc).to receive(:servers).and_return([server, server]).at_least(:once)
expect(server).to receive(:hostname).and_return("hostname").at_least(:once)
expect(server).to receive(:private_ipv4_address).and_return("10.0.0.0").at_least(:once)
expect(mc.generate_etc_hosts_entry).to eq("10.0.0.0 hostname\n10.0.0.0 hostname")
end
it "returns minio servers properly" do
expect(mc.servers.map(&:index)).to eq([0])
end
it "returns per pool storage size properly" do
expect(mc.storage_size_gib).to eq(100)
end
it "returns per pool server count properly" do
expect(mc.server_count).to eq(1)
end
it "returns per pool driver count properly" do
expect(mc.drive_count).to eq(1)
end
it "returns connection strings properly" do
expect(mc.servers.first.vm).to receive(:ephemeral_net4).and_return("1.1.1.1")
expect(mc.ip4_urls).to eq(["https://1.1.1.1:9000"])
end
end