Skip to content

Commit 4195908

Browse files
authored
Merge pull request #3321 from sttts/sttts-e2e-unused
🌱 test/e2e: cleanup framework
2 parents dfcda9f + 3e3a4f8 commit 4195908

35 files changed

+1638
-1974
lines changed

cmd/sharded-test-server/cache.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636

3737
"github.com/kcp-dev/kcp/cmd/test-server/helpers"
3838
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
39-
"github.com/kcp-dev/kcp/test/e2e/framework"
39+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4040
)
4141

4242
func startCacheServer(ctx context.Context, logDirPath, workingDir string, syntheticDelay time.Duration) (<-chan error, string, error) {
@@ -52,7 +52,7 @@ func startCacheServer(ctx context.Context, logDirPath, workingDir string, synthe
5252
)
5353
cacheWorkingDir := filepath.Join(workingDir, ".kcp-cache")
5454
cachePort := 8012
55-
commandLine := framework.Command("cache-server", "cache")
55+
commandLine := frameworkserver.Command("cache-server", "cache")
5656
commandLine = append(
5757
commandLine,
5858
fmt.Sprintf("--root-directory=%s", cacheWorkingDir),

cmd/sharded-test-server/frontproxy.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
"github.com/kcp-dev/kcp/cmd/sharded-test-server/third_party/library-go/crypto"
4242
"github.com/kcp-dev/kcp/cmd/test-server/helpers"
4343
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
44-
"github.com/kcp-dev/kcp/test/e2e/framework"
44+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4545
)
4646

4747
func startFrontProxy(
@@ -131,7 +131,7 @@ func startFrontProxy(
131131
}
132132

133133
// run front-proxy command
134-
commandLine := append(framework.Command("kcp-front-proxy", "front-proxy"),
134+
commandLine := append(frameworkserver.Command("kcp-front-proxy", "front-proxy"),
135135
fmt.Sprintf("--mapping-file=%s", filepath.Join(workDirPath, ".kcp-front-proxy/mapping.yaml")),
136136
fmt.Sprintf("--root-directory=%s", filepath.Join(workDirPath, ".kcp-front-proxy")),
137137
fmt.Sprintf("--root-kubeconfig=%s", filepath.Join(workDirPath, ".kcp/root.kubeconfig")),
@@ -248,7 +248,7 @@ func scrapeMetrics(ctx context.Context, cfg *rest.Config, workDir string) error
248248
if !set || promUrl == "" {
249249
return nil
250250
}
251-
return framework.ScrapeMetrics(ctx, cfg, promUrl, workDir, "kcp-front-proxy", filepath.Join(workDir, ".kcp-front-proxy/apiserver.crt"), map[string]string{
251+
return frameworkserver.ScrapeMetrics(ctx, cfg, promUrl, workDir, "kcp-front-proxy", filepath.Join(workDir, ".kcp-front-proxy/apiserver.crt"), map[string]string{
252252
"server": "kcp-front-proxy",
253253
})
254254
}

cmd/sharded-test-server/virtual.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"github.com/kcp-dev/kcp/cmd/sharded-test-server/third_party/library-go/crypto"
4343
"github.com/kcp-dev/kcp/cmd/test-server/helpers"
4444
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
45-
"github.com/kcp-dev/kcp/test/e2e/framework"
45+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4646
)
4747

4848
//go:embed *.yaml
@@ -186,7 +186,7 @@ func (v *VirtualWorkspace) start(ctx context.Context) error {
186186
auditFilePath = filepath.Join(v.logDirPath, fmt.Sprintf("kcp-virtual-workspaces-%d-audit.log", v.index))
187187
}
188188

189-
commandLine := framework.Command("virtual-workspaces", strings.ToLower(prefix))
189+
commandLine := frameworkserver.Command("virtual-workspaces", strings.ToLower(prefix))
190190
commandLine = append(commandLine, v.args...)
191191
commandLine = append(
192192
commandLine,

cmd/test-server/kcp/shard.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/kcp-dev/kcp/cmd/test-server/helpers"
4040
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
4141
"github.com/kcp-dev/kcp/test/e2e/framework"
42+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4243
)
4344

4445
//go:embed *.yaml
@@ -93,7 +94,7 @@ func (s *Shard) Start(ctx context.Context, quiet bool) error {
9394
}
9495

9596
// setup command
96-
commandLine := append(framework.StartKcpCommand(s.name), framework.TestServerArgs()...)
97+
commandLine := append(frameworkserver.StartKcpCommand(s.name), framework.TestServerArgs()...)
9798
commandLine = append(commandLine, s.args...)
9899
commandLine = append(commandLine,
99100
"--audit-log-maxsize", "1024",
@@ -291,7 +292,7 @@ func ScrapeMetrics(ctx context.Context, s *Shard, workDir string) error {
291292
return err
292293
}
293294

294-
return framework.ScrapeMetrics(ctx, config, promUrl, workDir, s.name, filepath.Join(s.runtimeDir, "apiserver.crt"), map[string]string{
295+
return frameworkserver.ScrapeMetrics(ctx, config, promUrl, workDir, s.name, filepath.Join(s.runtimeDir, "apiserver.crt"), map[string]string{
295296
"server": s.name,
296297
})
297298
}

test/e2e/apibinding/apibinding_webhook_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
"github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1"
4949
wildwestclientset "github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/client/clientset/versioned/cluster"
5050
"github.com/kcp-dev/kcp/test/e2e/framework"
51+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
5152
)
5253

5354
func TestAPIBindingMutatingWebhook(t *testing.T) {
@@ -141,7 +142,7 @@ func TestAPIBindingMutatingWebhook(t *testing.T) {
141142
},
142143
Deserializer: deserializer,
143144
}
144-
port, err := framework.GetFreePort(t)
145+
port, err := frameworkserver.GetFreePort(t)
145146
require.NoError(t, err, "failed to get free port for test webhook")
146147
dirPath := filepath.Dir(server.KubeconfigPath())
147148
testWebhooks[cluster].StartTLS(t, filepath.Join(dirPath, "apiserver.crt"), filepath.Join(dirPath, "apiserver.key"), port)
@@ -288,7 +289,7 @@ func TestAPIBindingValidatingWebhook(t *testing.T) {
288289
},
289290
Deserializer: deserializer,
290291
}
291-
port, err := framework.GetFreePort(t)
292+
port, err := frameworkserver.GetFreePort(t)
292293
require.NoError(t, err, "failed to get free port for test webhook")
293294
dirPath := filepath.Dir(server.KubeconfigPath())
294295
testWebhooks[cluster].StartTLS(t, filepath.Join(dirPath, "apiserver.crt"), filepath.Join(dirPath, "apiserver.key"), port)

test/e2e/audit/audit_log_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ import (
3131
"k8s.io/apiserver/pkg/apis/audit"
3232

3333
"github.com/kcp-dev/kcp/test/e2e/framework"
34+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
3435
)
3536

3637
func TestAuditLogs(t *testing.T) {
3738
t.Parallel()
3839
framework.Suite(t, "control-plane")
3940

40-
artifactDir, dataDir, err := framework.ScratchDirs(t)
41+
artifactDir, dataDir, err := frameworkserver.ScratchDirs(t)
4142
require.NoError(t, err)
4243

4344
server := framework.PrivateKcpServer(t,
44-
framework.WithCustomArguments(
45+
frameworkserver.WithCustomArguments(
4546
"--audit-policy-file", "./policy.yaml",
4647
),
47-
framework.WithScratchDirectories(artifactDir, dataDir),
48+
frameworkserver.WithScratchDirectories(artifactDir, dataDir),
4849
)
4950

5051
cfg := server.BaseConfig(t)

test/e2e/authorizer/authorizationorder_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
3232
"github.com/kcp-dev/kcp/test/e2e/framework"
33+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
3334
)
3435

3536
func TestAuthorizationOrder(t *testing.T) {
@@ -111,15 +112,15 @@ func TestAuthorizationOrder(t *testing.T) {
111112
})
112113
}
113114

114-
func setupTest(t *testing.T, authOrder, webhookConfigFile string) (framework.RunningServer, kcpclientset.ClusterInterface, kcpkubernetesclientset.ClusterInterface) {
115+
func setupTest(t *testing.T, authOrder, webhookConfigFile string) (frameworkserver.RunningServer, kcpclientset.ClusterInterface, kcpkubernetesclientset.ClusterInterface) {
115116
args := []string{
116117
"--authorization-webhook-config-file", webhookConfigFile,
117118
}
118119
if authOrder != "" {
119120
args = append(args, "--authorization-order", authOrder)
120121
}
121122

122-
server := framework.PrivateKcpServer(t, framework.WithCustomArguments(args...))
123+
server := framework.PrivateKcpServer(t, frameworkserver.WithCustomArguments(args...))
123124

124125
kcpConfig := server.BaseConfig(t)
125126
kubeClusterClient, err := kcpkubernetesclientset.NewForConfig(kcpConfig)
@@ -130,7 +131,7 @@ func setupTest(t *testing.T, authOrder, webhookConfigFile string) (framework.Run
130131
return server, kcpClusterClient, kubeClusterClient
131132
}
132133

133-
func verifyEndpointAccess(ctx context.Context, t *testing.T, server framework.RunningServer, endpoint string, shouldSucceed bool) {
134+
func verifyEndpointAccess(ctx context.Context, t *testing.T, server frameworkserver.RunningServer, endpoint string, shouldSucceed bool) {
134135
rootShardCfg := server.RootShardSystemMasterBaseConfig(t)
135136
if rootShardCfg.NegotiatedSerializer == nil {
136137
rootShardCfg.NegotiatedSerializer = kubernetesscheme.Codecs.WithoutConversion()

test/e2e/authorizer/workspace_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1"
3636
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
3737
"github.com/kcp-dev/kcp/test/e2e/framework"
38+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
3839
)
3940

4041
func TestWorkspaces(t *testing.T) {
@@ -44,7 +45,7 @@ func TestWorkspaces(t *testing.T) {
4445
server := framework.SharedKcpServer(t)
4546

4647
type runningServer struct {
47-
framework.RunningServer
48+
frameworkserver.RunningServer
4849
orgClusterName logicalcluster.Path
4950
kubeClusterClient kcpkubernetesclientset.ClusterInterface
5051
kcpClusterClient kcpclientset.ClusterInterface

test/e2e/cache/cache_server_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
cacheclient "github.com/kcp-dev/kcp/pkg/cache/client"
3939
"github.com/kcp-dev/kcp/pkg/cache/client/shard"
4040
"github.com/kcp-dev/kcp/test/e2e/framework"
41+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4142
cache2e "github.com/kcp-dev/kcp/test/e2e/reconciler/cache"
4243
)
4344

@@ -368,7 +369,7 @@ func TestCacheServerAllScenarios(t *testing.T) {
368369
t.Parallel()
369370
framework.Suite(t, "control-plane")
370371

371-
_, dataDir, err := framework.ScratchDirs(t)
372+
_, dataDir, err := frameworkserver.ScratchDirs(t)
372373
require.NoError(t, err)
373374
ctx, cancelFunc := context.WithCancel(context.Background())
374375
t.Cleanup(cancelFunc)

test/e2e/conformance/webhook_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1"
4646
wildwestclientset "github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/client/clientset/versioned/cluster"
4747
"github.com/kcp-dev/kcp/test/e2e/framework"
48+
frameworkserver "github.com/kcp-dev/kcp/test/e2e/framework/server"
4849
)
4950

5051
func TestMutatingWebhookInWorkspace(t *testing.T) {
@@ -88,7 +89,7 @@ func TestMutatingWebhookInWorkspace(t *testing.T) {
8889
Deserializer: deserializer,
8990
}
9091

91-
port, err := framework.GetFreePort(t)
92+
port, err := frameworkserver.GetFreePort(t)
9293
require.NoError(t, err, "failed to get free port for test webhook")
9394
dirPath := filepath.Dir(server.KubeconfigPath())
9495
testWebhook.StartTLS(t, filepath.Join(dirPath, "apiserver.crt"), filepath.Join(dirPath, "apiserver.key"), port)
@@ -206,7 +207,7 @@ func TestValidatingWebhookInWorkspace(t *testing.T) {
206207
Deserializer: deserializer,
207208
}
208209

209-
port, err := framework.GetFreePort(t)
210+
port, err := frameworkserver.GetFreePort(t)
210211
require.NoError(t, err, "failed to get free port for test webhook")
211212
dirPath := filepath.Dir(server.KubeconfigPath())
212213
testWebhook.StartTLS(t, filepath.Join(dirPath, "apiserver.crt"), filepath.Join(dirPath, "apiserver.key"), port)

test/e2e/framework/accessory.go

-101
This file was deleted.

0 commit comments

Comments
 (0)