Skip to content

Commit

Permalink
Rename as requested in review
Browse files Browse the repository at this point in the history
Signed-off-by: David Festal <dfestal@redhat.com>
  • Loading branch information
davidfestal committed Feb 7, 2023
1 parent 17a6ba8 commit 77af933
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions test/e2e/framework/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ func WithDownstreamPreparation(prepare func(config *rest.Config, isFakePCluster
}
}

// Create creates a SyncTarget resource through the `workload sync` CLI command,
// CreateSyncTargetAndApplyToDownstream creates a SyncTarget resource through the `workload sync` CLI command,
// applies the syncer-related resources in the physical cluster.
// No resource will be effectively synced after calling this method.
func (sf *syncerFixture) Create(t *testing.T) *appliedSyncerFixture {
func (sf *syncerFixture) CreateSyncTargetAndApplyToDownstream(t *testing.T) *appliedSyncerFixture {
t.Helper()

artifactDir, _, err := ScratchDirs(t)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/cluster/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestClusterController(t *testing.T) {
require.NoError(t, err)
t.Log("Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
})).Create(t).StartSyncer(t)
})).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

t.Logf("Bind second user workspace to location workspace")
framework.NewBindCompute(t, wsPath, source).Bind(t)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/reconciler/deployment/deployment_coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ func TestDeploymentCoordinator(t *testing.T) {
eastSyncer := framework.NewSyncerFixture(t, upstreamServer, locationWorkspacePath,
framework.WithSyncTargetName("east"),
framework.WithSyncedUserWorkspaces(workloadWorkspace1, workloadWorkspace2),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

_, err = kcpClusterClient.Cluster(locationWorkspacePath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "east", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"east"}]`), metav1.PatchOptions{})
require.NoError(t, err)

westSyncer := framework.NewSyncerFixture(t, upstreamServer, locationWorkspacePath,
framework.WithSyncTargetName("west"),
framework.WithSyncedUserWorkspaces(workloadWorkspace1, workloadWorkspace2),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

_, err = kcpClusterClient.Cluster(locationWorkspacePath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "west", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"west"}]`), metav1.PatchOptions{})
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestSyncTargetLocalExport(t *testing.T) {
framework.WithExtraResources("services"),
framework.WithSyncTargetName(syncTargetName),
framework.WithSyncedUserWorkspaces(computeWorkspace),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

framework.Eventually(t, func() (bool, string) {
syncTarget, err := kcpClients.Cluster(computePath).WorkloadV1alpha1().SyncTargets().Get(ctx, syncTargetName, metav1.GetOptions{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestMultipleExports(t *testing.T) {
)
require.NoError(t, err)
}),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

t.Logf("syncTarget should have one resource to sync")
require.Eventually(t, func() bool {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/locationworkspace/rootcompute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestRootComputeWorkspace(t *testing.T) {
)
require.NoError(t, err)
}),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

require.Eventually(t, func() bool {
syncTarget, err := kcpClients.Cluster(computePath).WorkloadV1alpha1().SyncTargets().Get(ctx, syncTargetName, metav1.GetOptions{})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/locationworkspace/synctarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestSyncTargetExport(t *testing.T) {
syncTarget := framework.NewSyncerFixture(t, source, computePath,
framework.WithAPIExports(fmt.Sprintf("%s:%s", schemaPath.String(), cowboysAPIExport.Name)),
framework.WithSyncTargetName(syncTargetName),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

require.Eventually(t, func() bool {
syncTarget, err := kcpClients.Cluster(computePath).WorkloadV1alpha1().SyncTargets().Get(ctx, syncTargetName, metav1.GetOptions{})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/namespace/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestNamespaceScheduler(t *testing.T) {
// so that there's a ready cluster to schedule to.
syncerFixture := framework.NewSyncerFixture(t, server, server.path,
framework.WithExtraResources("services"),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)
syncTargetName := syncerFixture.SyncerConfig.SyncTargetName

t.Logf("Bind to location workspace")
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/reconciler/scheduling/api_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func TestSchedulingOnSupportedAPI(t *testing.T) {
framework.WithSyncTargetName(firstSyncTargetName),
framework.WithSyncedUserWorkspaces(userWS),
framework.WithAPIExports(""),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

secondSyncTargetName := fmt.Sprintf("secondsynctarget-%d", +rand.Intn(1000000))
t.Logf("Creating a SyncTarget with global kubernetes APIExports in %s,and start both the Syncer APIImporter and Syncer HeartBeat", locationPath)
_ = framework.NewSyncerFixture(t, source, locationPath,
framework.WithSyncTargetName(secondSyncTargetName),
framework.WithSyncedUserWorkspaces(userWS),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

placementName := "placement-test-supportedapi"
t.Logf("Bind to location workspace")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/scheduling/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestScheduling(t *testing.T) {
framework.WithExtraResources("services"),
framework.WithSyncTargetName(syncTargetName),
framework.WithSyncedUserWorkspaces(userWorkspace, secondUserWorkspace),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

t.Logf("Wait for APIResourceImports to show up in the negotiation workspace")
require.Eventually(t, func() bool {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/reconciler/scheduling/multi_placements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ func TestMultiPlacement(t *testing.T) {
framework.WithSyncTargetName(firstSyncTargetName),
framework.WithExtraResources("services"),
framework.WithSyncedUserWorkspaces(userWorkspace),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

secondSyncTargetName := "second-synctarget"
t.Logf("Creating a SyncTarget and syncer in %s", locationPath)
secondSyncerFixture := framework.NewSyncerFixture(t, source, locationPath,
framework.WithExtraResources("services"),
framework.WithSyncTargetName(secondSyncTargetName),
framework.WithSyncedUserWorkspaces(userWorkspace),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

t.Log("Label synctarget")
patchData1 := `{"metadata":{"labels":{"loc":"loc1"}}}`
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/reconciler/scheduling/placement_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestPlacementUpdate(t *testing.T) {
framework.WithSyncTargetName(firstSyncTargetName),
framework.WithSyncedUserWorkspaces(userWorkspace),
framework.WithExtraResources("services"),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

t.Log("Wait for \"default\" location")
require.Eventually(t, func() bool {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/syncer/dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestDNSResolution(t *testing.T) {

syncer := framework.NewSyncerFixture(t, upstreamServer, locationWorkspacePath,
framework.WithSyncedUserWorkspaces(workloadWorkspace1, workloadWorkspace2),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)
syncer.WaitForSyncTargetReady(ctx, t)

downstreamKubeClient, err := kubernetes.NewForConfig(syncer.DownstreamConfig)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestSyncerLifecycle(t *testing.T) {
metav1.GroupResource{Group: "core.k8s.io", Resource: "persistentvolumes"},
)
require.NoError(t, err)
})).Create(t).StartSyncer(t)
})).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
Expand Down Expand Up @@ -621,7 +621,7 @@ func TestCordonUncordonDrain(t *testing.T) {
// response.
syncerFixture := framework.NewSyncerFixture(t, upstreamServer, wsPath,
framework.WithExtraResources("services"),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)
syncTargetName := syncerFixture.SyncerConfig.SyncTargetName

ctx, cancelFunc := context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/syncer/tunnels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestSyncerTunnel(t *testing.T) {

syncerFixture := framework.NewSyncerFixture(t, upstreamServer, synctargetWsName.Path(),
framework.WithSyncedUserWorkspaces(userWs),
).Create(t).StartSyncer(t)
).CreateSyncTargetAndApplyToDownstream(t).StartSyncer(t)

syncerFixture.WaitForSyncTargetReady(ctx, t)

Expand Down
24 changes: 12 additions & 12 deletions test/e2e/virtual/syncer/virtualworkspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
)
require.NoError(t, err)
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

kubelikeSyncer.StopHeartBeat(t)
kubelikeSyncer.StartHeartBeat(t)
Expand All @@ -254,7 +254,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

kubelikeVWDiscoverClusterClient, err := kcpdiscovery.NewForConfig(kubelikeSyncer.SyncerVirtualWorkspaceConfig)
require.NoError(t, err)
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Create two service accounts")
_, err := kubeClusterClient.Cluster(wildwestLocationPath).CoreV1().ServiceAccounts("default").Create(ctx, &corev1.ServiceAccount{
Expand Down Expand Up @@ -461,7 +461,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Bind wildwest location workspace to itself")
framework.NewBindCompute(t, wildwestLocationPath, server,
Expand Down Expand Up @@ -619,7 +619,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Bind consumer workspace to wildwest location workspace")
framework.NewBindCompute(t, consumerPath, server,
Expand Down Expand Up @@ -774,7 +774,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

_, err = kcpClusterClient.Cluster(wildwestLocationPath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "wildwest-north", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"north"}]`), metav1.PatchOptions{})
require.NoError(t, err)
Expand All @@ -793,7 +793,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

_, err = kcpClusterClient.Cluster(wildwestLocationPath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "wildwest-south", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"south"}]`), metav1.PatchOptions{})
require.NoError(t, err)
Expand Down Expand Up @@ -997,7 +997,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

_, err = kcpClusterClient.Cluster(wildwestLocationPath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "wildwest-north", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"north"}]`), metav1.PatchOptions{})
require.NoError(t, err)
Expand All @@ -1018,7 +1018,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

_, err = kcpClusterClient.Cluster(wildwestLocationPath).WorkloadV1alpha1().SyncTargets().Patch(ctx, "wildwest-south", types.JSONPatchType, []byte(`[{"op":"add","path":"/metadata/labels/region","value":"south"}]`), metav1.PatchOptions{})
require.NoError(t, err)
Expand Down Expand Up @@ -1325,7 +1325,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Bind consumer workspace to wildwest location workspace")
framework.NewBindCompute(t, consumerPath, server,
Expand Down Expand Up @@ -1433,7 +1433,7 @@ func TestSyncerVirtualWorkspace(t *testing.T) {
logWithTimestampf(t, "Installing test CRDs into sink cluster...")
fixturewildwest.FakePClusterCreate(t, sinkCrdClient.ApiextensionsV1().CustomResourceDefinitions(), metav1.GroupResource{Group: wildwest.GroupName, Resource: "cowboys"})
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Bind consumer workspace to wildwest location workspace")
framework.NewBindCompute(t, consumerPath, server,
Expand Down Expand Up @@ -1948,7 +1948,7 @@ func TestUpsyncerVirtualWorkspace(t *testing.T) {
)
require.NoError(t, err)
}),
).Create(t).StartAPIImporter(t).StartHeartBeat(t)
).CreateSyncTargetAndApplyToDownstream(t).StartAPIImporter(t).StartHeartBeat(t)

logWithTimestampf(t, "Bind upsyncer workspace")
framework.NewBindCompute(t, upsyncerPath, server,
Expand Down

0 comments on commit 77af933

Please sign in to comment.