-
Notifications
You must be signed in to change notification settings - Fork 4
✨ Add e2e tests for frontproxy objects #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SimonTheLeg
wants to merge
10
commits into
kcp-dev:main
Choose a base branch
from
SimonTheLeg:front-proxy-e2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−4
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
15f9b00
Add e2e test for simple fp creation
SimonTheLeg ce33dfa
make self-desctructing namespaces optional
SimonTheLeg d3d1806
Revert "make self-desctructing namespaces optional"
SimonTheLeg 742b359
point BinaryAssetDirectory for Ginkgo to new tools directory
SimonTheLeg 2073975
add instructions to running E2E tests locally
SimonTheLeg 3b98e30
template frontproxy externalhostname on frontproxy targeting kubeconfigs
SimonTheLeg 04cf36c
make frontproxy tests work
SimonTheLeg 73b458e
restrict the overly aggressive markdown linting
SimonTheLeg 97da797
importorder
SimonTheLeg 6b44d71
increase timeout
SimonTheLeg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//go:build e2e | ||
|
||
/* | ||
Copyright 2025 The KCP Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package frontproxies | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/go-logr/logr" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
ctrlruntime "sigs.k8s.io/controller-runtime" | ||
|
||
operatorv1alpha1 "github.com/kcp-dev/kcp-operator/sdk/apis/operator/v1alpha1" | ||
"github.com/kcp-dev/kcp-operator/test/utils" | ||
) | ||
|
||
func TestCreateFrontProxy(t *testing.T) { | ||
fmt.Println() | ||
|
||
ctrlruntime.SetLogger(logr.Discard()) | ||
|
||
client := utils.GetKubeClient(t) | ||
ctx := context.Background() | ||
namespace := "create-frontproxy" | ||
|
||
utils.CreateSelfDestructingNamespace(t, ctx, client, namespace) | ||
|
||
// deploy rootshard | ||
rootShard := utils.DeployRootShard(ctx, t, client, namespace) | ||
|
||
// deploy front-proxy | ||
frontProxy := utils.DeployFrontProxy(ctx, t, client, namespace, rootShard.Name) | ||
|
||
// create front-proxy kubeconfig | ||
configSecretName := "kubeconfig-front-proxy-e2e" | ||
|
||
fpConfig := operatorv1alpha1.Kubeconfig{} | ||
fpConfig.Name = "front-proxy" | ||
fpConfig.Namespace = namespace | ||
fpConfig.Spec = operatorv1alpha1.KubeconfigSpec{ | ||
Target: operatorv1alpha1.KubeconfigTarget{ | ||
FrontProxyRef: &corev1.LocalObjectReference{ | ||
Name: frontProxy.Name, | ||
}, | ||
}, | ||
Username: "e2e", | ||
Validity: metav1.Duration{Duration: 2 * time.Hour}, | ||
SecretRef: corev1.LocalObjectReference{ | ||
Name: configSecretName, | ||
}, | ||
Groups: []string{"system:masters"}, | ||
} | ||
|
||
t.Log("Creating kubeconfig for FrontProxy…") | ||
if err := client.Create(ctx, &fpConfig); err != nil { | ||
t.Fatal(err) | ||
} | ||
utils.WaitForObject(t, ctx, client, &corev1.Secret{}, types.NamespacedName{Namespace: fpConfig.Namespace, Name: fpConfig.Spec.SecretRef.Name}) | ||
|
||
// verify that we can use frontproxy kubeconfig to access rootshard workspaces | ||
t.Log("Connecting to FrontProxy…") | ||
kcpClient := utils.ConnectWithKubeconfig(t, ctx, client, namespace, fpConfig.Name) | ||
// proof of life: list something every logicalcluster in kcp has | ||
t.Log("Should be able to list Secrets.") | ||
secrets := &corev1.SecretList{} | ||
if err := kcpClient.List(ctx, secrets); err != nil { | ||
t.Fatalf("Failed to list secrets in kcp: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with this change? The hostname should be preferring the shard external hostname, because any interaction via kubectl plugins with use the external hostname exposed by the shard anyway. If I remember correctly we talked about this a while ago, in the current kcp way of doing things, this won't really work.