Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,81 @@ tests:
servicePublishingStrategy:
type: Route
route: {}

onUpdate:
- name: When capabilities disabled list is changed it should fail
initial: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
capabilities:
disabled:
- ImageRegistry
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: Route
route: {}
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
updated: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
capabilities:
disabled:
- Insights
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: Route
route: {}
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
expectedError: "Capabilities is immutable"
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,76 @@ tests:
- anything
- kas.duplicated.hostname.com
expectedError: "loadBalancer hostname cannot be in ClusterConfiguration.apiserver.servingCerts.namedCertificates"

onUpdate:
- name: When services publishing strategy type is changed it should fail
initial: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: Route
route: {}
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
updated: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: NodePort
nodePort:
address: "127.0.0.1"
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
expectedError: "Services is immutable"
Original file line number Diff line number Diff line change
Expand Up @@ -703,3 +703,77 @@ tests:
servicePublishingStrategy:
type: Route
route: {}

onUpdate:
- name: When controllerAvailabilityPolicy is changed it should fail
initial: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
controllerAvailabilityPolicy: HighlyAvailable
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: Route
route: {}
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
updated: |
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
spec:
controllerAvailabilityPolicy: SingleReplica
dns:
baseDomain: example.com
platform:
type: AWS
pullSecret:
name: secret
release:
image: quay.io/openshift-release-dev/ocp-release:4.15.11-x86_64
secretEncryption:
aescbc:
activeKey:
name: key
type: aescbc
services:
- service: APIServer
servicePublishingStrategy:
type: Route
route: {}
- service: OAuthServer
servicePublishingStrategy:
type: Route
route: {}
- service: Konnectivity
servicePublishingStrategy:
type: Route
route: {}
- service: Ignition
servicePublishingStrategy:
type: Route
route: {}
expectedError: "ControllerAvailabilityPolicy is immutable"
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package hcpstatus

import (
"testing"

. "github.com/onsi/gomega"

hyperv1 "github.com/openshift/hypershift/api/hypershift/v1beta1"
"github.com/openshift/hypershift/support/api"

configv1 "github.com/openshift/api/config/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

crclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

func TestHCPStatusReconciler(t *testing.T) {
t.Parallel()
g := NewWithT(t)

hcp := &hyperv1.HostedControlPlane{
ObjectMeta: metav1.ObjectMeta{
Name: "test-hcp",
Namespace: "test-ns",
},
}

clusterVersion := &configv1.ClusterVersion{
ObjectMeta: metav1.ObjectMeta{
Name: "version",
},
}

expectedOAuthConfigMapName := "oauth-metadata-configmap"
authentication := &configv1.Authentication{
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
},
Status: configv1.AuthenticationStatus{
IntegratedOAuthMetadata: configv1.ConfigMapNameReference{
Name: expectedOAuthConfigMapName,
},
},
}

mgmtClient := fake.NewClientBuilder().
WithScheme(api.Scheme).
WithObjects(hcp).
WithStatusSubresource(hcp).
Build()

guestClient := fake.NewClientBuilder().
WithScheme(api.Scheme).
WithObjects(clusterVersion, authentication).
Build()

reconciler := &hcpStatusReconciler{
mgtClusterClient: mgmtClient,
hostedClusterClient: guestClient,
}

// When reconciling HCP status with a guest Authentication resource, it should propagate authentication status to HCP
_, err := reconciler.Reconcile(t.Context(), reconcile.Request{
NamespacedName: types.NamespacedName{
Name: hcp.Name,
Namespace: hcp.Namespace,
},
})
g.Expect(err).NotTo(HaveOccurred())

updatedHCP := &hyperv1.HostedControlPlane{}
err = mgmtClient.Get(t.Context(), crclient.ObjectKeyFromObject(hcp), updatedHCP)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(updatedHCP.Status.Configuration).NotTo(BeNil())
g.Expect(updatedHCP.Status.Configuration.Authentication.IntegratedOAuthMetadata.Name).To(Equal(expectedOAuthConfigMapName))
}
Loading