Skip to content

Commit 8fda981

Browse files
committed
add inital integration test cases
1 parent 79cb02d commit 8fda981

File tree

74 files changed

+1369
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1369
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ tags
1919
.envrc
2020
authentication-operator
2121
telepresence.log
22+
/test-output/

pkg/cmd/mom/apply_configuration_command.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ func NewApplyConfigurationCommand(streams genericiooptions.IOStreams) *cobra.Com
1515
}
1616

1717
func RunApplyConfiguration(ctx context.Context, input libraryapplyconfiguration.ApplyConfigurationInput) (libraryapplyconfiguration.AllDesiredMutationsGetter, error) {
18-
// TODO initialize dynamic clients, informers, operator clients, and kubeclients from the input to demonstrate.
19-
2018
authenticationOperatorInput, err := operator.CreateOperatorInputFromMOM(ctx, input)
2119
if err != nil {
2220
return nil, fmt.Errorf("unable to configure operator input: %w", err)

pkg/cmd/mom/output_resources_command.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,28 @@ func RunOutputResources(ctx context.Context) (*libraryoutputresources.OutputReso
2222
ManagementResources: libraryoutputresources.ResourceList{
2323
ExactResources: []libraryoutputresources.ExactResourceID{
2424
libraryoutputresources.ExactClusterOperator("authentication"),
25-
libraryoutputresources.ExactResource("operator.openshift.io", "authentications", "", "cluster"),
25+
libraryoutputresources.ExactConfigMap("openshift-authentication", "audit"),
26+
libraryoutputresources.ExactConfigMap("openshift-authentication", "v4-0-config-system-trusted-ca-bundle"),
27+
libraryoutputresources.ExactDeployment("openshift-authentication", "oauth-openshift"),
28+
libraryoutputresources.ExactLowLevelOperator("authentications"),
29+
exactNamespace("openshift-authentication"),
30+
exactRole("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
31+
exactRoleBinding("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
32+
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-session"),
33+
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-ocp-branding-template"),
34+
exactService("openshift-authentication", "oauth-openshift"),
35+
libraryoutputresources.ExactServiceAccount("openshift-authentication", "oauth-openshift"),
36+
},
37+
EventingNamespaces: []string{
38+
"openshift-authentication-operator",
2639
},
2740
},
2841
UserWorkloadResources: libraryoutputresources.ResourceList{
2942
ExactResources: []libraryoutputresources.ExactResourceID{
30-
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-session"),
31-
libraryoutputresources.ExactSecret("openshift-authentication", "v4-0-config-system-ocp-branding-template"),
32-
libraryoutputresources.ExactServiceAccount("openshift-authentication", "oauth-openshift"),
33-
libraryoutputresources.ExactDeployments("openshift-authentication", "oauth-openshift"),
43+
libraryoutputresources.ExactClusterRoleBinding("system:openshift:openshift-authentication"),
3444
exactOAuthClient("openshift-browser-client"),
3545
exactOAuthClient("openshift-challenging-client"),
3646
exactOAuthClient("openshift-cli-client"),
37-
libraryoutputresources.ExactClusterRoleBinding("system:openshift:openshift-authentication"),
38-
libraryoutputresources.ExactRoleBinding("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
39-
libraryoutputresources.ExactRole("openshift-config-managed", "system:openshift:oauth-servercert-trust"),
4047
},
4148
GeneratedNameResources: []libraryoutputresources.GeneratedResourceID{
4249
libraryoutputresources.GeneratedCSR("system:openshift:openshift-authenticator-"),
@@ -48,3 +55,19 @@ func RunOutputResources(ctx context.Context) (*libraryoutputresources.OutputReso
4855
func exactOAuthClient(name string) libraryoutputresources.ExactResourceID {
4956
return libraryoutputresources.ExactResource("oauth.openshift.io", "oauthclients", "", name)
5057
}
58+
59+
func exactNamespace(name string) libraryoutputresources.ExactResourceID {
60+
return libraryoutputresources.ExactResource("", "namespaces", "", name)
61+
}
62+
63+
func exactService(namespace, name string) libraryoutputresources.ExactResourceID {
64+
return libraryoutputresources.ExactResource("", "services", namespace, name)
65+
}
66+
67+
func exactRole(namespace, name string) libraryoutputresources.ExactResourceID {
68+
return libraryoutputresources.ExactResource("rbac.authorization.k8s.io", "roles", namespace, name)
69+
}
70+
71+
func exactRoleBinding(namespace, name string) libraryoutputresources.ExactResourceID {
72+
return libraryoutputresources.ExactResource("rbac.authorization.k8s.io", "rolebindings", namespace, name)
73+
}

pkg/operator/replacement_starter.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,36 @@ type authenticationOperatorInput struct {
5959
const componentName = "cluster-authentication-operator"
6060

6161
func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfiguration.ApplyConfigurationInput) (*authenticationOperatorInput, error) {
62-
kubeClient, err := kubernetes.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
62+
// TODO replace with the library-go function in https://github.com/openshift/library-go/pull/1857 once it merges
63+
recommendedRESTConfig := &rest.Config{
64+
QPS: 1000,
65+
Burst: 10000,
66+
}
67+
kubeClient, err := kubernetes.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
6368
if err != nil {
6469
return nil, err
6570
}
66-
configClient, err := configclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
71+
configClient, err := configclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
6772
if err != nil {
6873
return nil, err
6974
}
70-
operatorClient, err := operatorclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
75+
operatorClient, err := operatorclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7176
if err != nil {
7277
return nil, err
7378
}
74-
routeClient, err := routeclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
79+
routeClient, err := routeclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7580
if err != nil {
7681
return nil, err
7782
}
78-
oauthClient, err := oauthclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
83+
oauthClient, err := oauthclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
7984
if err != nil {
8085
return nil, err
8186
}
82-
apiregistrationv1Client, err := apiregistrationclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
87+
apiregistrationv1Client, err := apiregistrationclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
8388
if err != nil {
8489
return nil, err
8590
}
86-
migrationClient, err := kubemigratorclient.NewForConfigAndClient(&rest.Config{}, momInput.MutationTrackingClient.GetHTTPClient())
91+
migrationClient, err := kubemigratorclient.NewForConfigAndClient(recommendedRESTConfig, momInput.MutationTrackingClient.GetHTTPClient())
8792
if err != nil {
8893
return nil, err
8994
}
@@ -100,16 +105,25 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig
100105
return nil, err
101106
}
102107

103-
eventRecorder := events.NewKubeRecorderWithOptions(
104-
kubeClient.CoreV1().Events("openshift-authentication-operator"),
105-
events.RecommendedClusterSingletonCorrelatorOptions(),
108+
//eventRecorder := events.NewKubeRecorderWithOptions(
109+
// kubeClient.CoreV1().Events("openshift-authentication-operator"),
110+
// events.RecommendedClusterSingletonCorrelatorOptions(),
111+
// componentName,
112+
// &corev1.ObjectReference{
113+
// Kind: "Deployment",
114+
// Namespace: "openshift-authentication-operator",
115+
// Name: "authentication-operator",
116+
// },
117+
//)
118+
// TODO figure out if we're better off using the event correlator (possible) and making a flush of some kind or if live write are better
119+
// but for now don't lose it.
120+
eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("openshift-authentication-operator"),
106121
componentName,
107122
&corev1.ObjectReference{
108123
Kind: "Deployment",
109124
Namespace: "openshift-authentication-operator",
110125
Name: "authentication-operator",
111-
},
112-
)
126+
})
113127

114128
return &authenticationOperatorInput{
115129
kubeClient: kubeClient,
@@ -299,7 +313,7 @@ func CreateOperatorStarter(ctx context.Context, authOperatorInput *authenticatio
299313

300314
oauthAPIServerRunOnceFns, oauthAPIServerRunFns, err := prepareOauthAPIServerOperator(ctx, authOperatorInput, informerFactories, resourceSyncer, versionRecorder)
301315
if err != nil {
302-
return nil, fmt.Errorf("unable to prepare oauth server: %w", err)
316+
return nil, fmt.Errorf("unable to prepare oauth apiserver: %w", err)
303317
}
304318
ret.ControllerRunFns = append(ret.ControllerRunFns, oauthAPIServerRunFns...)
305319
ret.ControllerNamedRunOnceFns = append(ret.ControllerNamedRunOnceFns, oauthAPIServerRunOnceFns...)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: Authentication
3+
metadata:
4+
annotations:
5+
operator.openshift.io/controller-name: TODO-resourceSyncer
6+
name: cluster
7+
status:
8+
conditions:
9+
- lastTransitionTime: "2024-10-14T22:38:20Z"
10+
message: an error on the server ("request namespace \"openshift-oauth-apiserver\"
11+
does not equal body namespace \"\"") has prevented the request from succeeding
12+
(delete secrets etcd-client)
13+
reason: Error
14+
status: "True"
15+
type: ResourceSyncControllerDegraded
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fieldManager: oauth-server-ResourceSync
2+
force: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: Authentication
3+
metadata:
4+
annotations:
5+
operator.openshift.io/controller-name: TODO-configOverridesController
6+
name: cluster
7+
status:
8+
conditions:
9+
- lastTransitionTime: "2024-10-14T22:38:20Z"
10+
reason: NoUnsupportedConfigOverrides
11+
status: "True"
12+
type: UnsupportedConfigOverridesUpgradeable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fieldManager: openshift-authentication-UnsupportedConfigOverrides
2+
force: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: Authentication
3+
metadata:
4+
annotations:
5+
operator.openshift.io/controller-name: TODO-configObserver
6+
name: cluster
7+
status:
8+
conditions:
9+
- lastTransitionTime: "2024-10-14T22:38:20Z"
10+
message: |-
11+
infrastructure.config.openshift.io "cluster" not found
12+
console.config.openshift.io "cluster" not found
13+
secret "v4-0-config-system-router-certs" not found
14+
oauth.config.openshift.io "cluster" not found
15+
reason: Error
16+
status: "True"
17+
type: OAuthServerConfigObservationDegraded
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fieldManager: oauth-server-ConfigObserver
2+
force: true

0 commit comments

Comments
 (0)