Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 e2e/apiexportendpointslice: use SharedKcpServer #2821

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

p0lyn0mial
Copy link
Contributor

Summary

it is possible to use a shared server because the
scheduler skips shards annotated with experimental.core.kcp.io/unschedulable

Related issue(s)

Fixes #

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 21, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jmprusi for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@p0lyn0mial p0lyn0mial force-pushed the e2e-endpointslice-shared-server branch from 87815a0 to 73cc8ef Compare February 21, 2023 15:46
@fgiloux
Copy link
Contributor

fgiloux commented Feb 22, 2023

This looks good to me. I just have a couple of points:

Can you please amend the comment here?

// Endpoint tests require the edition of shards.
// These tests are run on a private cluster to avoid side effects on other e2e tests.
// They require the resources previously created: APIExport, APIExportEndpointSlice, etc.

This could be a separate test function:

t.Logf("Creating a slice without partition")
sliceWithAll := &apisv1alpha1.APIExportEndpointSlice{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "my-slice-without-partition",
},
Spec: apisv1alpha1.APIExportEndpointSliceSpec{
APIExport: apisv1alpha1.ExportBindingReference{
Path: exportClusterPath.String(),
Name: slice.Spec.APIExport.Name,
},
},
}
sliceWithAll, err = sliceClient.Cluster(partitionClusterPath).Create(ctx, sliceWithAll, metav1.CreateOptions{})
require.NoError(t, err, "error creating APIExportEndpointSlice")
sliceWithAllName := sliceWithAll.Name
t.Logf("Getting the total number of shards in the system")
shards, err := shardClient.Cluster(core.RootCluster.Path()).List(ctx, metav1.ListOptions{})
require.NoError(t, err, "error listing Shards")
framework.Eventually(t, func() (bool, string) {
sliceWithAll, err := kcpClusterClient.Cluster(partitionClusterPath).ApisV1alpha1().APIExportEndpointSlices().Get(ctx, sliceWithAllName, metav1.GetOptions{})
require.NoError(t, err)
if len(sliceWithAll.Status.APIExportEndpoints) == len(shards.Items) {
for _, apiExportEndpoint := range sliceWithAll.Status.APIExportEndpoints {
found := false
for _, shard := range shards.Items {
if strings.Contains(apiExportEndpoint.URL, shard.Spec.VirtualWorkspaceURL) {
found = true
break
}
}
if !found {
return false, fmt.Sprintf("didn't find matching shard for %v endpoint, shards: %#v", apiExportEndpoint.URL, shards.Items)
}
}
return true, ""
}
return false, fmt.Sprintf("expected %d endpoint, but got: %#v", len(shards.Items), sliceWithAll.Status.APIExportEndpoints)
}, wait.ForeverTestTimeout, 100*time.Millisecond, "expecting a single endpoint for the root shard, got %d", len(sliceWithAll.Status.APIExportEndpoints))

It was not the case previously due to the cost of setting up the private environment

it is possible to use a shared server because the
scheduler skips shards annotated with "experimental.core.kcp.io/unschedulable"
@p0lyn0mial p0lyn0mial force-pushed the e2e-endpointslice-shared-server branch from 73cc8ef to 991003f Compare February 22, 2023 10:54
@p0lyn0mial
Copy link
Contributor Author

Updated the comment. IMO there is no need for extracting logic to a helper function. I like when tests are self-contained and self-descriptive.

@fgiloux
Copy link
Contributor

fgiloux commented Feb 22, 2023

Updated the comment. IMO there is no need for extracting logic to a helper function. I like when tests are self-contained and self-descriptive.

I did not mean a helper function. I meant a completely separate test function as it is not directly related to the tests part of the same function. It is not critical, just thinking it may be nicer.

return true, ""
}
return false, fmt.Sprintf("expected 1 endpoint, but got: %#v", sliceWithAll.Status.APIExportEndpoints)
return false, fmt.Sprintf("expected %d endpoint, but got: %#v", len(shards.Items), sliceWithAll.Status.APIExportEndpoints)
Copy link
Contributor

@fgiloux fgiloux Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned that you may be introducing a flake here: What does guarantee that no shard was created by a parallel test case between your call to list shards and the one to get the APIExportEndpointSlices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, assuming schedulable shards won't be removed we could change this logic to expect >= initial shards+ shards added by this tests.

@p0lyn0mial
Copy link
Contributor Author

I did not mean a helper function. I meant a completely separate test function as it is not directly related to the tests part of the same function. It is not critical, just thinking it may be nicer.

ah, this could be a default (happy-path) scenario I always wanted, yeah I can do that :)

@mjudeikis
Copy link
Contributor

@kcp-dev/kcp-contributors lets pick this up?

@kcp-ci-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
After a furter 30 days, they will turn rotten.
Mark the issue as fresh with /remove-lifecycle stale.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kcp-ci-bot kcp-ci-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiexports lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants