Skip to content

Commit a44ce1e

Browse files
authored
docs(e2e): trim the comments added in this series
Review feedback on kube-logging#2301. The comments this series added explained more than the code needed. Cut to one line each where they earn it and dropped where they did not: 27 lines of prose down to 8, plus assertion messages that only restated the expected value. Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
1 parent bc808c2 commit a44ce1e

6 files changed

Lines changed: 12 additions & 31 deletions

File tree

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ CRD_OPTIONS ?= crd:maxDescLen=0
5454

5555
E2E_TEST_TIMEOUT ?= 20m
5656

57-
# go test runs this many suite binaries at a time, which bounds peak kind
58-
# clusters by the parallel tests inside them instead of by the core count. With
59-
# 4 the heaviest combination is fluentd-aggregator's 4 tests, volumedrain's 2 and
60-
# one each from two more, so at most 8 against the 17 an unbounded run creates.
57+
# Concurrent suite binaries, so peak kind clusters stops following the core count.
6158
E2E_CLUSTERS ?= 4
6259

6360
TEST_COV_DIR := $(shell mkdir -p build/_test_coverage && realpath build/_test_coverage)

e2e/common/cluster.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ import (
3535
"github.com/kube-logging/logging-operator/e2e/internal/kind"
3636
)
3737

38-
// clusterStopTimeout bounds the wait for cluster.Start to return once the
39-
// context is canceled, so a runnable that will not stop is named here instead
40-
// of running the whole binary out of its -timeout.
38+
// clusterStopTimeout bounds the wait for cluster.Start to return after cancel.
4139
const clusterStopTimeout = time.Minute
4240

4341
type Cluster interface {
@@ -78,18 +76,14 @@ func WithCluster(name string, t *testing.T, fn func(*testing.T, Cluster), before
7876
assert.NoError(t, cluster.Cleanup())
7977
cancel()
8078

81-
// Start's error is checked here rather than in the goroutine: FailNow is
82-
// undefined off the test goroutine, so a cluster that never started used
83-
// to be dropped and resurface as an unrelated Eventually timeout.
79+
// Checked here, not in the goroutine: FailNow is undefined off the test one.
8480
select {
8581
case err := <-startErr:
8682
assert.NoError(t, err, "starting the cluster")
8783
case <-time.After(clusterStopTimeout):
8884
assert.Fail(t, "cluster.Start did not return after cancellation")
8985
}
9086

91-
// A cluster that came down cleanly must not fail the test on kind's own
92-
// kubeconfig bookkeeping, so this matches the assertions above.
9387
assert.NoError(t, DeleteTestCluster(name))
9488
}()
9589

e2e/common/kind.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ const KindClusterCreationTimeout = "3m"
3232

3333
var kindCLI = kind.New()
3434

35-
// kubeconfigDir is one directory per run, created 0700 by MkdirTemp. The file
36-
// names inside it are predictable, the directory is not, so nothing planted at a
37-
// guessable path in the shared temp directory can be written through.
35+
// kubeconfigDir is one 0700 directory per run, so the paths in it are unguessable.
3836
var kubeconfigDir = sync.OnceValues(func() (string, error) {
3937
return os.MkdirTemp("", "e2e-kubeconfig-*")
4038
})
@@ -50,11 +48,8 @@ func ClusterKubeconfigPath(name string) (string, error) {
5048
return filepath.Join(dir, "kind-"+name+".kubeconfig"), nil
5149
}
5250

53-
// RemoveClusterKubeconfig drops the file and the lock kind leaves beside it.
54-
// kind rewrites the kubeconfig rather than unlinking it, so without this a run
55-
// that was killed hands its leftovers to the next one. The directory goes with
56-
// the last cluster of the binary; until then it is not empty and Remove is a
57-
// no-op on it.
51+
// RemoveClusterKubeconfig drops the file and the lock kind leaves beside it,
52+
// which kind itself does not. The directory goes with the binary's last cluster.
5853
func RemoveClusterKubeconfig(name string) error {
5954
path, err := ClusterKubeconfigPath(name)
6055
if err != nil {

e2e/common/kind_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func TestClusterKubeconfigPath(t *testing.T) {
2828
beta, err := ClusterKubeconfigPath("beta")
2929
require.NoError(t, err)
3030

31-
require.NotEqual(t, alpha, beta, "two clusters sharing one file is the lock contention")
31+
require.NotEqual(t, alpha, beta)
3232
require.Equal(t, filepath.Dir(alpha), filepath.Dir(beta))
3333

3434
again, err := ClusterKubeconfigPath("alpha")
3535
require.NoError(t, err)
3636
require.Equal(t, alpha, again, "create and delete have to name the same file")
3737

3838
dir := filepath.Dir(alpha)
39-
require.NotEqual(t, os.TempDir(), dir, "a path directly in the shared temp directory is guessable")
39+
require.NotEqual(t, os.TempDir(), dir, "a path in the shared temp directory is guessable")
4040

4141
info, err := os.Stat(dir)
4242
require.NoError(t, err)
@@ -51,15 +51,14 @@ func TestRemoveClusterKubeconfig(t *testing.T) {
5151
require.NoError(t, RemoveClusterKubeconfig("gamma"))
5252

5353
require.NoFileExists(t, path)
54-
require.NoFileExists(t, lock, "kind leaves the lock behind when it is killed mid-write")
54+
require.NoFileExists(t, lock)
5555
}
5656

5757
func TestRemoveClusterKubeconfigToleratesMissingFiles(t *testing.T) {
5858
require.NoError(t, RemoveClusterKubeconfig("never-created"))
5959
}
6060

61-
// stubKubeconfig recreates the per-run directory when an earlier case has
62-
// already taken it away, so the cases here do not depend on their order.
61+
// stubKubeconfig recreates the directory a previous case may have removed.
6362
func stubKubeconfig(t *testing.T, name string) string {
6463
t.Helper()
6564

e2e/internal/kind/commands.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ func (k *Kind) CreateCluster(options CreateClusterOptions) error {
110110

111111
case errors.Is(err, ErrTimeout):
112112
// kind removes a half-built cluster when one of its own actions fails,
113-
// but not when we kill it, so the leftovers have to go explicitly. The
114-
// kubeconfig has to come along: this delete runs when creates are timing
115-
// out together, which is when a shared one loses the lock.
113+
// but not when we kill it, so the leftovers have to go explicitly.
116114
cleanupErr := k.deleteCluster(k.CleanupTimeout, DeleteClusterOptions{
117115
Name: options.Name,
118116
Kubeconfig: options.Kubeconfig,

e2e/internal/kind/commands_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ func TestInvocations(t *testing.T) {
266266
want: []string{"create cluster --name fine"},
267267
},
268268
// kind tears down a half-built cluster when one of its own actions
269-
// fails, but not when we kill it, so the delete has to be ours. It has
270-
// to name the create's kubeconfig too: this is the delete that runs while
271-
// several creates are timing out together.
269+
// fails, but not when we kill it, so the delete has to be ours.
272270
"a stalled create deletes the partial cluster": {
273271
sleepEnv: "FAKE_KIND_CREATE_SLEEP",
274272
timeout: shortTimeout,

0 commit comments

Comments
 (0)