Originally, this test used the conntrack binary to check the conntrack
state, so it used the distroless-iptables image (the base of the
kube-proxy image) as a helper, since that contained the conntrack
binary. But later, we removed conntrack from that image after
kube-proxy no longer needed it, and the test got updated to read
/proc/net/nf_conntrack directly. Thus, there is no longer any reason
to be using distroless-iptables (and forcing the distroless-iptables
image to contain "sleep", "cat", and "grep").
(The test still had code to use the conntrack binary if
/proc/net/nf_conntrack was unavailable, but this fallback would never
be used because the image it was using never contained that binary.)
Production code should not depend on the testing package. Helper packages
should be more flexible and support other implementations like
ktesting.TContext.
Valid exceptions are type assertions.
This makes the test helper code more flexible. In particular, passing a
ktesting.TContext instance is okay: it implements all required methods, but
isn't *testing.T and cannot implement testing.TB (private method).
Instead of a new testutils.TB interface, ktesting.TB could have been used. This
is not done because TContext usage should go together with other changes (for
example, merging with ctx or client parameters and renaming to tCtx). That can
be done later if desired.
A potential downside of the custom interface, loosing printf checking, gets
avoided by making the connection to testing.T visible.
Remove KeyEncipherment from ECDSA certs in pod cert and log tests.
Add test for pki helpers after the update in pki helpers.
Signed-off-by: Adonis Murati <adonismurati@gmail.com>
Supporting the apiextensions client was done for the sake of completeness, but
would extend the set of dependencies of client-go. That isn't worth it, in
particular considering that tests which need this can easily construct the
client locally.
The goal is to make it easier to read the source top-to-bottom.
The previous organization had historic reasons.
The structure is now:
- doc.go: package docs
- tcontext.go: TContext and most of its methods
- assert.go: Gomega integration
- signal*.go: signal handling, including progress reporting
- contexthelper.go: utility code
- ktesting.go: global setup and compatibility with klog's ktesting
This was done purely via copy-and-paste, with one exception: run(tCtx, ...)
became tCtx.run and the comment was dropped because it was obvious.
Tests were not touched and still pass.
Init cancels its TContext automatically when the test ends, via
runWhenDone (context.AfterFunc on the test's own context). withTB,
used by TContext.Run for sub-tests, never set this up, so a
sub-test's TContext was only canceled when the whole parent test
finished, not when that sub-test itself ended. Found when using the new
ktesting semantic more widely.
SyncTest has a related but distinct problem: even with the above
fixed, automatic cancellation via context.AfterFunc runs the
callback in a new goroutine, but synctest checks for durably
blocked goroutines the instant the bubble's main goroutine returns,
with no guarantee that the AfterFunc goroutine ran in time. Fixed
by canceling synchronously via defer around the callback instead.
Currently running tests are tracked and their names are shown for
progress reports generated inside them.
As before, once we intercept the Ginkgo spec context, the result is
not a full ginkgo.SpecContext. That's okay because Gomega only needs
AttachProgressReporter. The cleanup test was checking for more than
that and therefore needs to be updated.
To make the output `tCtx.Log` and `tCtx.Logger().Info` consistent, the logger
has to be updated via WithName and (because that is how WithName is implemented
in the klog test logger) the tCtx.Log output must switch from ": " to "/" as
separator.
Code which wants to return an error with backtrace can now create one via
NewFailure.
Test failures (both direct and via Gomega) now also capture the backtrace when
wrapped with WithError, which is then shown by ExpectNoError. Log output for
an unexpected error is more concise.
This adds the same README.md to all ktesting packages for visitors of the
GitHub repo. The actual documentation is inside the Go doc comments.
The package doc of the main ktesting package is meant to be a full introduction
of all concepts, including those that are implemented elsewhere.
Doing a full pass over the entire functionality and examples led to some TODOs
around bugs and enhancements. Those will be addressed separately.
This became possible when Context was added to the testing package. Before,
Init could only cancel the context when its cleanup function was invoked, which
is after the test ended.
Canceling exactly when the test ends is more natural because then all cleanup
functions registered by a test can wait for code started inside the test to
stop without having to call tCtx.Cancel explicitly first. Those workarounds
will removed separately, they remain valid because TContext.Cancel is
idempotent.
However, this is still a breaking change for code which depends on the TContext
*not* being canceled yet when a TContext.Cleanup callback is invoked. Such code
must be moved into a defer callback of the main test function. In more
complicated cases when a helper wants to run such code, it has to manage the
cancellation order itself.
CancelBecause is an alternative to the existing Cancel which allows the caller
to control the entire cancellation cause. This can be useful for propagating
the cause of one context to another.
While at it, refactor such that canceledError is used in fewer places.
Switch e2e tests to the freshly promoted test images:
- agnhost 2.66.1
- nginx 1.27.0-2 and 1.28.0-2
- glibc-dns-testing 2.1.1
Promoted in kubernetes/k8s.io#9787 and kubernetes/k8s.io#9788.
All four tags verified live on registry.k8s.io with digests
matching the promotion manifests.
The agnhost bump follows build/dependencies.yaml refPaths: the
manifest.go config, the kitten and nautilus BASEIMAGE files, and
the yaml fixtures that hardcode the tag.
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
The Projected PodCertificate mTLS test built the client fetch URL from
the partially qualified name "server.<namespace>.svc". Windows pods
treat any name containing a "." as an FQDN and skip DNS search-suffix
resolution, so partially qualified service names do not resolve there.
Build the fetch URL from the fully qualified service name using the
cluster DNS domain so the client resolves the server on both Linux and
Windows.
Some code in test/utils/runners.go was only used by scheduler_perf.
Therefore it belongs under test/integration/scheduler_perf where it can be
maintained by SIG Scheduling.
The new version includes a generic /envvar endpoint in netexec that
reads any named environment variable, enabling e2e tests to retrieve
spec.nodeName via the Downward API instead of relying on os.Hostname().
Ref: https://github.com/kubernetes/k8s.io/pull/9608
Signed-off-by: Jitesh Kumar <jiteshkumardj@gmail.com>
Kubelet lacks --emulated-version support and cannot toggle feature gates
that are locked in the binary. Modified ToggleFeatureGates to exclude
locked feature gates from kubelet's --feature-gates.