|
| 1 | +/* |
| 2 | +Copyright 2026. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +*/ |
| 10 | + |
| 11 | +package controller |
| 12 | + |
| 13 | +import ( |
| 14 | + . "github.com/onsi/ginkgo/v2" |
| 15 | + . "github.com/onsi/gomega" |
| 16 | +) |
| 17 | + |
| 18 | +var _ = Describe("serverStateCondition", func() { |
| 19 | + DescribeTable("maps server state and power status", |
| 20 | + func(state, powerStatus string, wantReady bool, wantReason, wantMessage string, wantWarn bool) { |
| 21 | + ready, reason, message, warn := serverStateCondition(state, powerStatus) |
| 22 | + Expect(ready).To(Equal(wantReady)) |
| 23 | + Expect(reason).To(Equal(wantReason)) |
| 24 | + Expect(message).To(Equal(wantMessage)) |
| 25 | + Expect(warn).To(Equal(wantWarn)) |
| 26 | + }, |
| 27 | + Entry("active and running", "ACTIVE", "RUNNING", true, "", "", false), |
| 28 | + Entry("unknown state", "", "", true, "", "", false), |
| 29 | + Entry("active but crashed", "ACTIVE", "CRASHED", false, "InstanceCrashed", |
| 30 | + "server crashed (state ACTIVE, power status CRASHED)", true), |
| 31 | + Entry("active with power error", "ACTIVE", "ERROR", false, "InstancePowerError", |
| 32 | + "server power error (state ACTIVE, power status ERROR)", true), |
| 33 | + Entry("creating", "CREATING", "", false, "InstanceStarting", "server is starting (state CREATING)", false), |
| 34 | + Entry("rebooting", "REBOOTING", "RUNNING", false, "InstanceBusy", |
| 35 | + "server is temporarily unavailable (state REBOOTING, power status RUNNING)", false), |
| 36 | + Entry("stopping", "STOPPING", "RUNNING", false, "InstanceStopping", |
| 37 | + "server is stopping (state STOPPING, power status RUNNING)", false), |
| 38 | + Entry("stopped", "INACTIVE", "STOPPED", false, "InstanceStopped", |
| 39 | + "server is stopped (state INACTIVE, power status STOPPED)", true), |
| 40 | + Entry("deallocating", "DEALLOCATING", "STOPPED", false, "InstanceDeallocating", |
| 41 | + "server is being deallocated (state DEALLOCATING, power status STOPPED)", false), |
| 42 | + Entry("deallocated", "DEALLOCATED", "STOPPED", false, "InstanceDeallocated", |
| 43 | + "server is deallocated (state DEALLOCATED, power status STOPPED)", true), |
| 44 | + Entry("paused", "PAUSED", "", false, "InstancePaused", "server is paused (state PAUSED)", true), |
| 45 | + Entry("entering rescue", "RESCUING", "", false, "InstanceEnteringRescue", |
| 46 | + "server is entering rescue mode (state RESCUING)", false), |
| 47 | + Entry("leaving rescue", "UNRESCUING", "", false, "InstanceLeavingRescue", |
| 48 | + "server is leaving rescue mode (state UNRESCUING)", false), |
| 49 | + Entry("rescue", "RESCUE", "RUNNING", false, "InstanceInRescue", |
| 50 | + "server is in rescue mode (state RESCUE, power status RUNNING)", true), |
| 51 | + Entry("deleting", "DELETING", "", false, "InstanceDeleting", "server is being deleted (state DELETING)", false), |
| 52 | + Entry("error", "ERROR", "ERROR", false, "InstanceFailed", "server failed (state ERROR, power status ERROR)", true), |
| 53 | + Entry("undocumented state", "SOMETHING", "", false, "InstanceNotActive", |
| 54 | + "server is not active (state SOMETHING)", false), |
| 55 | + ) |
| 56 | +}) |
0 commit comments