Commit Graph

34 Commits

Author SHA1 Message Date
Patrick Ohly
c008732948 test/integration: add StartEtcd
In contrast to EtcdMain, it can be called by individual tests or benchmarks and
each caller will get a fresh etcd instance. However, it uses the same
underlying code and the same port for all instances, so tests cannot run in
parallel.
2023-02-28 23:05:17 +01:00
Davanum Srinivas
4ecb4670cc
Remove unnecessary ETCD_UNSUPPORTED_ARCH for arm64
we should only use this env var for `arm`, since `arm64` is fully
supported by etcd folks, let us drop this!

(ex - https://github.com/etcd-io/etcd/releases/tag/v3.5.6)

ppc64le comment should be dropped as well

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-02-16 21:29:13 -05:00
Patrick Ohly
f131cabfa0 test: use go-uber/goleak for strict leak checking
It provides more readable output and has additional APIs for using it inside a
unit test. goleak.IgnoreCurrent is needed to filter out the goroutine that gets
started when importing go.opencensus.io/stats/view.

In order to handle background goroutines that get created on demand and cannot
be stopped (like the one for LogzHealth), a helper function ensures that those
are running before calling goleak.IgnoreCurrent. Keeping those goroutines
running is not a problem and thus not worth the effort of adding new APIs to
stop them.

Other goroutines are genuine leaks for which no fix is available. Those get
suppressed via IgnoreTopFunction, which works as long as that function
is unique enough.

Example output for the leak fixed in https://github.com/kubernetes/kubernetes/pull/115423:

    E0202 09:30:51.641841   74789 etcd.go:205] "EtcdMain goroutine check" err=<
        found unexpected goroutines:
        [Goroutine 4889 in state chan receive, with k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop on top of the stack:
        goroutine 4889 [chan receive]:
        k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop(0xc0076183c0)
        	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:268 +0x65
        created by k8s.io/apimachinery/pkg/watch.NewBroadcaster
        	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:77 +0x116
    >
2023-02-14 12:11:37 +01:00
Davanum Srinivas
1671efe7a8
Do not use a global variable for etcdURL
we are saving this information in an env variable `KUBE_INTEGRATION_ETCD_URL`

So just pick it up from there when needed. Currently when someone uses
framework.RunCustomEtcd directly, the global variable is *not* set and the
code that uses `GetEtcdURL` returns empty string.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-01-22 14:11:26 -05:00
Wojciech Tyczyński
1b976760db Improve debuggability of leaking goroutines 2022-11-07 15:04:08 +01:00
Wojciech Tyczyński
7253f708a8 Decrease goroutines 2022-11-04 10:34:36 +01:00
Monis Khan
4e68e9b5ad
kms: fix go routine leak in gRPC connection
Signed-off-by: Monis Khan <mok@microsoft.com>
2022-09-08 11:46:57 -04:00
Anish Ramasekar
f19f3f4099
Implement KMS v2alpha1
- add feature gate
- add encrypted object and run generated_files
- generate protobuf for encrypted object and add unit tests
- move parse endpoint to util and refactor
- refactor interface and remove unused interceptor
- add protobuf generate to update-generated-kms.sh
- add integration tests
- add defaulting for apiVersion in kmsConfiguration
- handle v1/v2 and default in encryption config parsing
- move metrics to own pkg and reuse for v2
- use Marshal and Unmarshal instead of serializer
- add context for all service methods
- check version and keyid for healthz

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2022-08-03 19:04:47 +00:00
Wojciech Tyczyński
ef607d131f Prevent from future leaks of goroutines in integration tests 2022-07-26 20:08:09 +02:00
Kubernetes Prow Robot
743238e951
Merge pull request #108048 from aojea/custom_etcd_integration
integration: custom etcd gracefully termination
2022-05-03 17:18:48 -07:00
Antonio Ojea
1756fe60d4 integration: custom etcd gracefully termination
when running integration tests without an external etcd, the framework
spawns an etcd instance executing it in its own process and killing
it once the test stops.

Instead of killing it directly, allow etcd to exit gracefully or kill
it after 5 seconds.
2022-04-18 19:09:38 +02:00
Antonio Ojea
2660ac8a6d integration framework: log number of leaked goroutines 2022-03-01 15:31:13 +01:00
ahrtr
fe95aa614c io/ioutil has already been deprecated in golang 1.16, so replace all ioutil with io and os 2022-02-03 05:32:12 +08:00
Patrick Ohly
81b4a695b3 test/integration: skip etcd startup for -help flag
By parsing flags in the test's main function before starting etcd we bail out
early without ever starting etcd when the test was invoked with -help.

Otherwise etcd must be available, gets started and then hangs because
flag.Parse itself exits when called by testing.go. This bypasses the code in
EtcdMain which normally stops etcd.
2021-09-24 11:51:58 +02:00
Jordan Liggitt
52b629efbc Drop use of deprecated clientv3.SetLogger 2021-06-15 09:53:06 -04:00
Jordan Liggitt
2979c3325e Switch to go.etcd.io/etcd/client/v3 2021-06-15 09:53:06 -04:00
Marek Siarkowicz
12447bc803 Upgrade etcd server version to 3.5.0-rc.0 2021-06-09 17:00:05 +02:00
Benjamin Elder
1a7cf6c91a remove bazel logic from test/integration/framework 2021-03-07 15:27:44 -08:00
tiloso
3cbdc711de Fix staticcheck in test/integration/{examples,framework}
Part of #92402, fixes staticcheck failures SA1006, SA1019 and SA2002 in
test/integration/examples and test/integration/framework.
2020-12-14 21:54:37 +01:00
wojtekt
af61e8fbdf Test watchcache being updated in multietcd setup 2020-09-15 08:19:13 +02:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Wenjia Zhang
3b274fad2a Replace github.com/coreos/etcd by go.etcd.io/etcd 2019-10-24 14:09:24 -07:00
Bin Lu
34f95a8985 Bug fix: remove etcd related issues in bazel-test-integration
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-06-04 22:09:48 -07:00
Kubernetes Prow Robot
01f0be4901
Merge pull request #76639 from lubinsz/pr_bzl_arm64
Add an environment variable for bazel-test-integration on Arm
2019-05-17 02:04:06 -07:00
Bin Lu
51ee2b1f0b Add an environment variable for bazel-test-integration on Arm
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-05-16 16:53:18 +08:00
Jordan Liggitt
aee1997a19 quiet integration test logs 2019-04-20 02:20:31 -04:00
Andrew Sy Kim
e26157df07 fix link to etcd install docs 2019-03-26 13:40:18 -04:00
Bin Lu
973a3c7233 Add bazel-test-integration for Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-03-08 14:01:15 +08:00
Ben Moss
34ac4d9ee9 Update deprecated links 2019-02-15 09:13:07 -05:00
Davanum Srinivas
8c8c01f913
Add debug logs for etcd server in integration tests
Change-Id: Ic1dd8a7c7e0adef27b969007e24c2eb089d6bb12
2019-01-04 15:22:29 -05:00
Davanum Srinivas
954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Jonathan Basseri
117288e285 Make integration test work with go test.
The EtcdMain function in integration tests is designed to launch an etcd
instance only when running in a bazel test. For non-bazel, we rely on
hack/make-rules/test-integration.sh to bring up the etcd instance.

This patch fixes the following in EtcdMain:
1. If etcd is not found in ${RUNFILES_DIR} then look in ${PATH}.
2. Try to connect to the etcd started by `make test-integraion`; if it
   is up, then don't start etcd.
3. Gracefully shut down etcd after tests.
4. Get a port from the OS instead of deriving it from argv[0].
5. Don't use sync.Once.

The benefit of this change is that integration tests work with `go test`
as well as `make test-integration` without users needing to do anything
special. That makes it much easier to pass go testing flags to tests and
integrate with IDEs.
2018-09-10 14:12:25 -07:00
dhilipkumars
fd8758b047 Extend apiserver testserver such that in can be used in integration tests
abstract out etcd server creation
test/integration/framework: cleanup master_utils.go
kube-apiserver: move StartTestServer tests into test/integration/master
Fix the failing scale test
kube-apiserver's TestServer now returns a struct instead of individual values
2017-11-22 15:16:25 +05:30
Mike Danese
8e23c656ca add testmain setup func to the integration framework 2017-07-12 17:34:55 -07:00