@@ -147,24 +147,27 @@ var _ = Describe("OpenStackProvisionServer Webhook", func() {
147147 Name : "test-provisionserver-2" ,
148148 Namespace : namespace ,
149149 }
150- // Create first provision server with specific port
150+ // Create first provision server and let it auto-assign an available port
151151 spec := map [string ]interface {}{
152152 "osImage" : "edpm-hardened-uefi.qcow2" ,
153153 "osContainerImageUrl" : "quay.io/podified-antelope-centos9/edpm-hardened-uefi:current-podified" ,
154154 "apacheImageUrl" : "registry.redhat.io/ubi9/httpd-24:latest" ,
155155 "agentImageUrl" : "quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:latest" ,
156- "port" : int64 (6200 ),
157156 }
158157 DeferCleanup (th .DeleteInstance , CreateProvisionServer (provisionServerName , spec ))
159158 })
160159
161160 It ("should fail when trying to use same port" , func () {
161+ // Get the port that was auto-assigned to the first provision server
162+ instance := GetProvisionServerDirect (provisionServerName )
163+ assignedPort := instance .Spec .Port
164+
162165 spec := map [string ]interface {}{
163166 "osImage" : "edpm-hardened-uefi.qcow2" ,
164167 "osContainerImageUrl" : "quay.io/podified-antelope-centos9/edpm-hardened-uefi:current-podified" ,
165168 "apacheImageUrl" : "registry.redhat.io/ubi9/httpd-24:latest" ,
166169 "agentImageUrl" : "quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:latest" ,
167- "port" : int64 (6200 ), // Same as first server
170+ "port" : int64 (assignedPort ), // Same as first server
168171 }
169172 raw := map [string ]interface {}{
170173 "apiVersion" : "baremetal.openstack.org/v1beta1" ,
@@ -185,12 +188,12 @@ var _ = Describe("OpenStackProvisionServer Webhook", func() {
185188 })
186189
187190 It ("should succeed when using different port" , func () {
191+ // Don't specify port - it will auto-assign a different available port
188192 spec := map [string ]interface {}{
189193 "osImage" : "edpm-hardened-uefi.qcow2" ,
190194 "osContainerImageUrl" : "quay.io/podified-antelope-centos9/edpm-hardened-uefi:current-podified" ,
191195 "apacheImageUrl" : "registry.redhat.io/ubi9/httpd-24:latest" ,
192196 "agentImageUrl" : "quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:latest" ,
193- "port" : int64 (6201 ), // Different port
194197 }
195198 raw := map [string ]interface {}{
196199 "apiVersion" : "baremetal.openstack.org/v1beta1" ,
0 commit comments