@@ -72,6 +72,32 @@ var _ = Describe("CloudStackMachineReconciler", func() {
72
72
return false
73
73
}, timeout ).WithPolling (pollInterval ).Should (BeTrue ())
74
74
})
75
+
76
+ It ("Should replace ds.mete_data.hostname with capi machine name." , func () {
77
+ // Mock a call to GetOrCreateVMInstance and set the machine to running.
78
+ mockCloudClient .EXPECT ().GetOrCreateVMInstance (
79
+ gomock .Any (), gomock .Any (), gomock .Any (),
80
+ gomock .Any (), gomock .Any (), gomock .Any ()).Do (
81
+ func (arg1 , _ , _ , _ , _ , userdata interface {}) {
82
+ Ω (userdata == dummies .CAPIMachine .Name ).Should (BeTrue ())
83
+ arg1 .(* infrav1.CloudStackMachine ).Status .InstanceState = "Running"
84
+ }).AnyTimes ()
85
+
86
+ // Have to do this here or the reconcile call to GetOrCreateVMInstance may happen too early.
87
+ setupMachineCRDs ()
88
+
89
+ // Eventually the machine should set ready to true.
90
+ Eventually (func () bool {
91
+ tempMachine := & infrav1.CloudStackMachine {}
92
+ key := client.ObjectKey {Namespace : dummies .ClusterNameSpace , Name : dummies .CSMachine1 .Name }
93
+ if err := k8sClient .Get (ctx , key , tempMachine ); err == nil {
94
+ if tempMachine .Status .Ready == true {
95
+ return true
96
+ }
97
+ }
98
+ return false
99
+ }, timeout ).WithPolling (pollInterval ).Should (BeTrue ())
100
+ })
75
101
})
76
102
77
103
Context ("With a fake ctrlRuntimeClient and no test Env at all." , func () {
0 commit comments