active()->create(['datacenter' => 'fsn', 'node' => 'pve']); $order = Order::factory()->withSubscription()->create(['datacenter' => 'fsn', 'plan' => 'start']); $instance = Instance::factory()->create([ 'order_id' => $order->id, 'customer_id' => $order->customer_id, 'host_id' => $host->id, 'vmid' => 101, 'status' => 'provisioning', ]); $run = ProvisioningRun::factory()->create([ 'subject_type' => Order::class, 'subject_id' => $order->id, 'pipeline' => 'customer', 'context' => [ 'instance_id' => $instance->id, 'host_id' => $host->id, 'node' => 'pve', 'vmid' => 101, 'subdomain' => $instance->subdomain, 'plan' => 'start', ], ]); return compact('host', 'order', 'instance', 'run'); } // Drei Blöcke à 20 GB nutzbar / 22 GB belegt kommen direkt als // SubscriptionAddon-Zeile dazu, statt über BookAddon zu buchen — das würde // einen Lieferlauf anstoßen und Stripe befragen, was hier nichts zur Sache // tut; gefragt ist nur, was ResizeVirtualMachine aus einer bereits gebuchten // Zeile macht. // // Ziel: 100 (Kontingent) + 60 (drei Blöcke à 20) + 20 (Kopfraum des Pakets, // 120-100) + 6 (Kopfraum der Blöcke, 66-60 belegt) = 186 GB. it('vergrößert die Platte um Paket- und Block-Kopfraum, und nur einmal', function () { $s = fakeServices(); ['run' => $run, 'instance' => $instance, 'order' => $order] = packHeadroomRun(); SubscriptionAddon::create([ 'subscription_id' => $order->subscription->id, 'addon_key' => AddonCatalogue::STORAGE, 'price_cents' => 1000, 'currency' => 'EUR', 'quantity' => 3, 'booked_at' => now(), 'pack_gb' => 20, 'pack_disk_gb' => 22, ]); expect(app(ResizeVirtualMachine::class)->execute($run)->type)->toBe('advance') ->and($s['pve']->resizeCalls)->toContain('101:scsi0:186G') ->and($instance->fresh()->disk_gb)->toBe(186); // Wiederholungslauf: das Ziel ist absolut, nicht '+…', also darf ein // zweiter Durchlauf nicht noch einmal vergrößern. $s['pve']->resizeCalls = []; expect(app(ResizeVirtualMachine::class)->execute($run->fresh())->type)->toBe('advance') ->and($s['pve']->resizeCalls)->toBe([]) ->and($instance->fresh()->disk_gb)->toBe(186); });