Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Oct 4, 2024
1 parent 6c27ccc commit d713541
Showing 1 changed file with 137 additions and 45 deletions.
182 changes: 137 additions & 45 deletions service/test/agama/storage/config_solver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@
"filesystem" => "xfs", "outline" => { "required" => false }
},
{
"mount_path" => "swap", "filesystem" => "swap",
"outline" => { "required" => false }
"mount_path" => "swap", "filesystem" => "swap", "size" => { "auto" => true },
"outline" => {
"auto_size" => {
"adjust_by_ram" => true,
"base_min" => "2 GiB",
"base_max" => "4 GiB"
}
}
},
{ "mount_path" => "", "filesystem" => "ext4",
"size" => { "min" => "100 MiB" } }
Expand Down Expand Up @@ -162,20 +168,26 @@
{
drives: [
{
partitions: [
{
filesystem: { path: "/" }
},
{
filesystem: { path: "/home" }
},
{}
]
partitions: partitions
}
]
}
end

let(:partitions) do
[
{
filesystem: { path: "/" }
},
{
filesystem: { path: "/home" }
},
{}
]
end

let(:scenario) { "disks.yaml" }

it "sets a size according to the product info" do
subject.solve(config)

Expand All @@ -195,57 +207,137 @@
expect(p3.size.max).to eq(Y2Storage::DiskSize.unlimited)
end

context "and the config does not specify any of the size fallbacks" do
partition_proc = proc { |c| c.drives.first.partitions.first }

context "and there is a device assigned" do
let(:partitions) do
[
{
search: "/dev/vda2",
filesystem: { path: "/" }
}
]
end

# Enable fallbacks and snapshots to check they don't affect in this case.
let(:min_fallbacks) { ["/home"] }
let(:max_fallbacks) { ["/home"] }
let(:snapshots_increment) { "300%" }

it "sets the device size" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(false)
expect(partition.size.min).to eq(20.GiB)
expect(partition.size.max).to eq(20.GiB)
end
end

context "and the product defines size fallbacks" do
let(:min_fallbacks) { ["/home"] }
let(:max_fallbacks) { ["/home"] }
# let(:snapshots_increment) { "300%" }
let(:snapshots_increment) { "300%" }

let(:config_json) do
{
drives: [
context "and the config does not specify some of the paths" do
let(:partitions) do
[
{
partitions: [
{
filesystem: { path: "/" }
}
]
filesystem: {
type: "xfs",
path: "/"
}
}
]
}
end
end

it "sets a size adding the fallbacks" do
it "sets a size adding the fallback sizes" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(true)
expect(partition.size.min).to eq(10.GiB)
expect(partition.size.max).to eq(Y2Storage::DiskSize.unlimited)
end

context "and snapshots are enabled" do
let(:partitions) do
[
{
filesystem: {
type: "btrfs",
path: "/"
}
}
]
end

it "sets a size adding the fallback and snapshots sizes" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(true)
expect(partition.size.min).to eq(40.GiB)
expect(partition.size.max).to eq(Y2Storage::DiskSize.unlimited)
end
end
end
end

context "and there is a device assigned" do
let(:scenario) { "disks.yaml" }

let(:config_json) do
{
drives: [
context "and the config specifies the fallback paths" do
let(:partitions) do
[
{
partitions: [
{
search: "/dev/vda2",
filesystem: { path: "/" }
}
]
filesystem: {
type: filesystem,
path: "/"
}
},
{
filesystem: { path: "/home" }
}
]
}
end

let(:filesystem) { "xfs" }

it "sets a size ignoring the fallback sizes" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(true)
expect(partition.size.min).to eq(5.GiB)
expect(partition.size.max).to eq(10.GiB)
end

context "and snapshots are enabled" do
let(:filesystem) { "btrfs" }

it "sets a size adding the snapshots size" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(true)
expect(partition.size.min).to eq(20.GiB)
expect(partition.size.max).to eq(40.GiB)
end
end
end
end

it "sets the device size" do
subject.solve(config)
context "and the volume has to be enlarged according to RAM size" do
before do
allow_any_instance_of(Y2Storage::Arch).to receive(:ram_size).and_return(8.GiB)
end

drive = config.drives.first
partition = drive.partitions.first
let(:partitions) do
[
{
filesystem: { path: "swap" }
}
]
end

expect(partition.size.default?).to eq(false)
expect(partition.size.min).to eq(20.GiB)
expect(partition.size.max).to eq(20.GiB)
it "sets the RAM size" do
subject.solve(config)
partition = partition_proc.call(config)
expect(partition.size.default?).to eq(true)
expect(partition.size.min).to eq(8.GiB)
expect(partition.size.max).to eq(8.GiB)
end
end
end
Expand Down

0 comments on commit d713541

Please sign in to comment.