Commit Graph

38 Commits

Author SHA1 Message Date
ChengHao Yang
029d314e15 Replace NewIndexerInformerWatcher with NewIndexerInformerWatcherWithLogger
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2025-09-12 01:44:02 +08:00
Patrick Ohly
7e9b228ff0 apply integration test: fix ordering test flake
Most of the time the managed fields were returned in the order as expected,
but not always. Semantically the order is irrelevant, so the comparison gets
relaxed to ignore it by normalizing first.
2025-09-03 16:50:42 +02:00
Mayuka Channankaiah
ffe306d679 client-go, kubectl: Replace deprecated ErrWaitTimeout with recommended method (#132718)
* client-go: Replace depracted ErrWaitTimeout with recommended method

* Fix UT and Integration tests

* IT test
2025-07-24 07:56:27 -07:00
Patrick Ohly
a1a85ddb16 SSA: test optional map keys
As of structured-merge-diff v6.3.0, list map keys may be optional, as long as
at least one key is provided.
2025-07-17 09:56:28 +02:00
Patrick Ohly
3357e8fc05 SSA: add integration tests
test/integration/apiserver/apply covers the behavior of server-side-apply (SSA)
for official APIs. But there seem to be no integration tests which cover the
semantic of SSA like adding/removing/updating entries in a list map. This adds
such a test.

It needs an API which is under control of the test and uses
k8s.io/apimachinery/pkg/apis/testapigroup for that purpose, with some issues
fixed (OpenAPI code generation complained) and a new list map added.

Registering that API group in the apiserver needs a REST storage and
strategy. The API group only gets added in the test. However, the production
code has to know about it. In particular,
pkg/generated/openapi/zz_generated.openapi.go has to describe it.
2025-07-17 09:56:28 +02:00
Kubernetes Prow Robot
28e4f3f6a3 Merge pull request #131350 from pohly/etcd-output
etcd output interception
2025-06-26 04:46:29 -07:00
Lukasz Szaszkiewicz
b8b3984874 client-go/reflector: stop exposing UseWatchList (#132453)
* client-go/reflector: stop exposing UseWatchList

* apiserver/cacher: stop setting reflector.UseWatchList

* test/integration/watchlist: fix TestReflectorWatchListFallback
2025-06-25 04:04:29 -07:00
Patrick Ohly
f74424bd7c etcd: better logging
Previously, etcd wrote to stderr in JSON format:

   {"level":"warn","ts":"2025-04-11T03:32:06.676527Z","caller":"embed/config.go:689","msg":"Running http and grpc server on single port. This is not recommended for production."}
   {"level":"warn","ts":"2025-04-11T03:32:06.676707Z","caller":"embed/config.go:689","msg":"Running http and grpc server on single port. This is not recommended for production."}
   {"level":"warn","ts":"2025-04-11T03:32:06.677056Z","caller":"etcdmain/etcd.go:146","msg":"failed to start etcd","error":"listen tcp 127.0.0.1:37803: bind: address already in use"}
   {"level":"fatal","ts":"2025-04-11T03:32:06.677104Z","caller":"etcdmain/etcd.go:204","msg":"discovery failed","error":"listen tcp 127.0.0.1:37803: bind: address already in use","stacktrace":"go.etcd.io/etcd/server/v3/etcdmain.startEtcdOrProxyV2\n\tgo.etcd.io/etcd/server/v3/etcdmain/etcd.go:204\ngo.etcd.io/etcd/server/v3/etcdmain.Main\n\tgo.etcd.io/etcd/server/v3/etcdmain/main.go:40\nmain.main\n\tgo.etcd.io/etcd/server/v3/main.go:31\nruntime.main\n\truntime/proc.go:272"}

This has several drawbacks:
- Not very readable.
- When used in tests which start etcd themselves (for example, scheduler_perf),
  the output is not associated with the current test.
- Contains warnings that are confusing for developers who don't know that they
  are harmless.

Intercepting output, parsing it and reformating makes the output nicer. Instead
of a mixture of JSON messages (see above) and normal test output, we now get
the etcd output embedded inside the test output. We can also filter out some
known harmless messages. Cleaning up more output or avoiding it in the first
place might be a good next step.

With `go test -v ./test/integration/scheduler_perf/dra`:

    === RUN   TestSchedulerPerf
    === RUN   TestSchedulerPerf/SchedulingWithResourceClaimTemplate
    === RUN   TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast
    I0411 13:21:03.353458   65212 feature_gate.go:385] feature gates: {map[SchedulerQueueingHints:false]}
    ...
    I0411 13:21:10.552975   65212 cidrallocator.go:210] stopping ServiceCIDR Allocator Controller
    I0411 13:21:10.567327   65212 etcd.go:210] "etcd output" logger="TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast" error="accept tcp 127.0.0.1:42245: use of closed network connection" level="warn" ts="2025-04-11T13:21:10.567045+0200" caller="embed/serve.go:160" msg="stopping insecure grpc server due to error"
    I0411 13:21:10.567398   65212 etcd.go:210] "etcd output" logger="TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast" ts="2025-04-11T13:21:10.567198+0200" caller="embed/serve.go:162" msg="stopped insecure grpc server due to error" error="accept tcp 127.0.0.1:42245: use of closed network connection" level="warn"
    I0411 13:21:15.567917   65212 etcd.go:227] "etcd didn't exit in 5 seconds, killing it" logger="TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast"
    I0411 13:21:15.567964   65212 etcd.go:234] "etcd exited" logger="TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast" err="signal: terminated"

With per-test output `go test -v ./test/integration/scheduler_perf/dra -args -use-testing-log`:

    === RUN   TestSchedulerPerf
    === RUN   TestSchedulerPerf/SchedulingWithResourceClaimTemplate
    === RUN   TestSchedulerPerf/SchedulingWithResourceClaimTemplate/fast
    I0411 13:19:03.540497   28645 feature_gate.go:385] feature gates: {map[DynamicResourceAllocation:true]}
    ...
    I0411 13:19:10.519994   28645 cidrallocator.go:210] stopping ServiceCIDR Allocator Controller
        etcd.go:210: I0411 13:19:10.533131] etcd output msg="stopping insecure grpc server due to error" error="accept tcp 127.0.0.1:46637: use of closed network connection" level="warn" ts="2025-04-11T13:19:10.532900+0200" caller="embed/serve.go:160"
        etcd.go:210: I0411 13:19:10.533274] etcd output msg="stopped insecure grpc server due to error" error="accept tcp 127.0.0.1:46637: use of closed network connection" level="warn" ts="2025-04-11T13:19:10.533022+0200" caller="embed/serve.go:162"
        etcd.go:227: I0411 13:19:15.533715] etcd didn't exit in 5 seconds, killing it
        etcd.go:234: I0411 13:19:15.533803] etcd exited err="signal: terminated"
2025-04-24 08:54:13 +02:00
xyz-li
e38b7dcaf7 integration/api: check field items in empty List
Signed-off-by: xyz-li <hui0787411@163.com>
2024-07-31 08:49:57 +08:00
Kubernetes Prow Robot
3f9b79fc11 Merge pull request #125145 from xyz-li/fix_watch_namespace
apiserver: fix watch namespace
2024-06-18 10:39:44 -07:00
xyz-li
818fabe37b apiserver: fix watch namespace
For request like '/api/v1/watch/namespaces/*', don't set scope.namespace.
Because the func `addWatcher` add a watcher to allWatchers with the value `scope.namespace` not empty.
But the function `dispatchEvent` dispatch event with an empty namespace.

Signed-off-by: xyz-li <hui0787411@163.com>
2024-06-18 11:53:28 +08:00
Antonio Ojea
6552f2710f use default flags for apiserver on integration tests 2024-06-04 22:09:35 +00:00
Lukasz Szaszkiewicz
41e706600a client-go/reflector: make UseWatchList a pointer
until #115478(use streaming against the etcd storage)
is resolved the cacher need a way to disable the streaming.
2024-01-19 14:40:18 +01:00
Lukasz Szaszkiewicz
9b32a47ab6 integration/apimachinery: add TestReflectorWatchListFallback integration test 2023-10-03 14:56:50 +02:00
Wojciech Tyczyński
41d7ddee1a Clean shutdown of apimachinery integration tests 2022-06-14 13:55:31 +02:00
Kubernetes Prow Robot
1ad8613d5c Merge pull request #109790 from p0lyn0mial/users-watchtools-informerwatcher
users of watchtools.NewIndexerInformerWatcher should wait for the informer to sync
2022-05-24 08:52:05 -07:00
Lukasz Szaszkiewicz
4a7845b485 users of watchtools.NewIndexerInformerWatcher should wait for the informer to sync
previously users of this method were relying on the fact that a call to LIST was made.
Instead, users should use the dedicated `HasSynced` method.
2022-05-24 13:05:40 +02:00
Wojciech Tyczyński
deef9e40de Simplify Create/Delete-TestingNamespace functions 2022-05-15 23:06:26 +02:00
Kir Kolyshkin
8820f4d381 TestWatchRestartsIfTimeoutNotReached: fix
This fixes the following error:

> test/integration/apimachinery/watch_restart_test.go:232:5: call to (*T).Fatalf from a non-test goroutine

Update: the previous fix (commit 1ce55e3afe that uses panic)
looks way too severe; it seems it is enough to call t.Errorf and return
from goroutine. The test will time out and fail anyway.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-03-23 10:19:38 -07:00
Davanum Srinivas
1ce55e3afe fix govet on golang 1.18
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-03-23 08:02:53 -04:00
Kubernetes Prow Robot
341d312066 Merge pull request #97350 from FabianKramm/master
kubectl proxy: append context host path to request path
2021-08-20 11:19:31 -07:00
fabiankramm
b1a6f8cdf9 kubectl proxy: append context host path to request path
Signed-off-by: fabiankramm <fab.kramm@googlemail.com>
2021-08-19 17:32:19 +02:00
Mengjiao Liu
6871b2b3c7 Rename masterConfig to controlPlaneConfig 2021-06-04 20:55:08 +08:00
Mengjiao Liu
387154f1a9 Part3: master to controlplane in test/integration
Rename RunAMaster to RunAControlPlane
2021-06-03 11:06:19 +08:00
Jordan Liggitt
bd2d63dd57 Fix closing of decorated watcher channel on timeout 2021-06-02 15:25:31 -04:00
Mengjiao Liu
c9ec486287 Part of master to controlplane in test/integration
Rename NewIntegrationTestMasterConfig to NewIntegrationTestControlPlaneConfig
2021-05-25 13:26:28 +08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Jordan Liggitt
c778008420 Shorten watch restart test, run in parallel 2020-07-23 17:17:29 -04:00
Jordan Liggitt
343c1e7636 Fix client watch reestablishment handling of client-side timeouts 2020-03-30 17:48:00 -04:00
Mike Danese
25651408ae generated: run refactor 2020-02-08 12:30:21 -05:00
Mike Danese
3aa59f7f30 generated: run refactor 2020-02-07 18:16:47 -08:00
Jordan Liggitt
5d5b444c4d Remove use of testapi codecs, selflink, resourcepath functions 2019-12-13 11:56:29 -05:00
Daniel (Shijun) Qian
5268f69405 fix duplicated imports of k8s code (#77484)
* fix duplicated imports of api/core/v1

* fix duplicated imports of client-go/kubernetes

* fix duplicated imports of rest code

* change import name to more reasonable
2019-05-08 10:12:47 -07:00
Jordan Liggitt
3bbd9b2c55 tag test/integration/apimachinery as integration test 2019-04-20 02:20:31 -04:00
Tomas Nozicka
09af8485f2 Add Until based on RetryWatcher 2019-02-26 16:21:38 +01:00
Tomas Nozicka
b762d2c0d7 Make UntilWithSync wait for integrated informers to stop 2019-01-21 18:30:00 +01:00
Tomas Nozicka
dc2cfd5d20 Update Bazel 2018-08-15 13:34:31 +02:00
Tomas Nozicka
866cc1acab Add UntilWithSync (informer based) 2018-08-15 13:34:31 +02:00