Commit Graph

16418 Commits (bc9e433ca26be0314a37c8c6ead66429a584bbc9)

Author SHA1 Message Date
Piotr Tabor bc9e433ca2 tools: Migrate remaining tools to gobin
Replace ./scripts/install_tool.sh with `gobin`, such that we have
consistent handling for all tools needed for build and consistent
versioning within ./tools/mod/go.mod.

Side changes:
  - Expose /scripts/fix.sh that fixes formatting and bom across modules
  - Expose *.sh variants of scripts like build and ./test (first step
towards replacement).
  - Make stderr output of commands explicit and make commands use
different color than callouts.
2020-10-13 19:33:01 +02:00
Joe Betz 061d8e8ead
Merge pull request #12354 from ptabor/202009027-module-pkgs
Modularization: Make pkg a module (and distribute not pkg code)
2020-10-13 12:56:21 -04:00
vivian 667ed96957
wal: remove redundant war tmp dirs if create wal failed (#12388)
If we create 000000000-0000000.war failed in war tmp dir(XXX.tmp) and we should
remove the tmp dirs. If create war successfully in tmp dir and it will
be renamed to common dir and remove tmp dir(XXX.tmp) will also be ok.

Co-authored-by: yangweiwei <yangweiwei@cmss.chinamobile.com>
2020-10-13 08:11:52 -07:00
Piotr Tabor f408939aa1 bom: Update bill-of-materials generation logic (and refresh bom). 2020-10-13 07:50:08 +02:00
Piotr Tabor 04f63b6571 go.mod,tests: Update go.mod for tests and . to reflect new dependencies. 2020-10-13 00:09:27 +02:00
Piotr Tabor de55bb6331 pkg: Rename imports after making 'pkg' a module
find -name '*.go' | xargs sed --follow-symlinks -i 's|go.etcd.io/etcd/v3/pkg/|go.etcd.io/etcd/pkg/v3/|g'
go fmt ./...
2020-10-13 00:09:27 +02:00
Piotr Tabor bfa91d48af pkg: Estabilish pkg as a module 2020-10-12 23:58:09 +02:00
Piotr Tabor 1983c89e27 pkg/logutil, etcdserver: Move zap-raft logger to etcdserver.
This package depends on raft and is solelly used by etcdserver/raft.go.
So it does not fullfills conditions of:
```
pkg/ is a collection of utility packages used by etcd without being specific to etcd itself. A package belongs here
only if it could possibly be moved out into its own repository in the future.
```
2020-10-12 23:58:09 +02:00
Piotr Tabor 5ba46f625f pkg/mock: Update imports to point on new files locations.
find ./ -name '*.go' | xargs sed -i 's|go.etcd.io/etcd/v3/pkg/mock/mockserver|go.etcd.io/etcd/v3/client/mock/mockserver|g'
find ./ -name '*.go' | xargs sed -i 's|go.etcd.io/etcd/v3/pkg/mock|go.etcd.io/etcd/v3/server/mock|g'
go fmt ./...
2020-10-12 23:58:09 +02:00
Piotr Tabor 28036db6f0 Mechanical: Move mock packages out of ./pkg
Mechanical execution of:

```
git mv ./pkg/mock/mockserver ./client/pkg/mock
git mv ./pkg/mock/{mockstorage,mockstore,mockwait} ./server/pkg/mock
```

The packages depend on etcd API / protos - so they are NOT etcd-dependencies.
In such situation thay should be placed in 'pkg' folder.
2020-10-12 23:58:09 +02:00
Gyuho Lee 0b95e8cef1
Merge pull request #12374 from ptabor/20201009-new-genproto
script/genproto.sh: Refactor to be explicit about versions.
2020-10-12 14:25:43 -07:00
Gyuho Lee fa83da446b
Merge pull request #12369 from ptabor/20201007-snapshot-out
Modularization: clientv3/snapshot -> etcdctl/snapshot
2020-10-12 14:24:45 -07:00
Sahdev Zala 891c69a5cf
Merge pull request #12386 from 2hamed/patch-1
README: Fixed the link to `functional` test dir
2020-10-12 14:55:48 -04:00
Hamed Momeni 386bf316a4 README: Fixed the link to test dir 2020-10-11 20:40:34 +02:00
Piotr Tabor 30811a06aa etcdctl, clientv3/snapshot: snapshot (Restore,Status) code out of client
"snapshot" Restore/Status code was the only remaining dependency of client on 'server'
code. The code is solelly used by etcdctl. Long-term the snapshot code
should be migrated to 'etcdadm' style of tool such that we can
distinguish tool solelly depending on networking API vs. tools that
operation on etcd files directly.

We left snapshot.Save() code in clientv3.snapshot package, such that
clients can benefits from automated download&safe to file snapshot
functionality over the wire.
2020-10-10 14:14:57 +02:00
Piotr Tabor 00e49d0c10
build: Fix updating 'go.etcd.io/etcd/api/v3/version.GitSHA' + test (#12382)
During move of code to 'api' (0aab02e7b5),
I overlooked that the ./build script is setting the version on the 'symbol'.

I added a code to ./build script that checks whether the symbol's are in sync.
2020-10-09 17:32:15 -07:00
Sam Batschelet e1bf097928
Merge pull request #12266 from chaitanyaenr/etcd_fsync_alert
Add alerts for etcd fsync duration
2020-10-09 14:42:12 -04:00
Joe Betz bc0d8dad1e
Merge pull request #12380 from ptabor/20201009-move-single-integration
[important] tests/integration: Move misplaced integration test integration/v3_kv_test.go
2020-10-09 13:14:15 -04:00
Piotr Tabor 485030052a tests/integration: Move misplaces integration tests.
There was undetected 'conflict' between
  11ba1a6109
and 2c66612e0e.

Moving the file to proper location.
2020-10-09 09:39:55 +02:00
Josh Bleecher Snyder 24724af7f1
etcdserver: prevent crash using expvars when server is not running (#12376)
The raft.status expvar is added at init time.
This change ensures that evaluating that expvar variable
doesn't panic during evaluation, even when there is
no server running.
2020-10-08 17:37:25 -07:00
CFC4N 11ba1a6109
namespace: check IsWithFromKey if keyLen equal 0. (#12307)
* namespace: check IsWithFromKey if keyLen equal 0.

Rename function isWithFromKey/isWithPrefix to IsOptsWithFromKey/IsOptsWithPrefix.

fixes: #12282

* integration: add test while WithFromKey/WithPrefix called in opts.
2020-10-08 17:34:09 -07:00
Piotr Tabor dfdda47bd8 script/genproto.sh: Refactor to be explicit about versions.
Refactoring script/genproto.sh around state-of-the-art techniques of
managing tooling in go:
  - https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
  - uses https://github.com/myitcv/gobin instead of customly created gopath.proto dir
  - caches tools between executions
  - guaratees hermetics runs (it was not guaranteed for protoc_grpc_gateway that used latest)

The change is no-op for the generated code.

The commit reveals a few 'worring things':
  1  We depend on : github.com/grpc-ecosystem/grpc-gateway/@v/v1.4.1/protoc-gen-grpc-gateway
  2. And also     : github.com/grpc-ecosystem/grpc-gateway/@v/v1.15.0/protoc-gen-swagger/protoc-gen-swagger
  3. And on extremely old: github.com/gogo/protobuf@v1.0.0 protoc-gen-gofast that is out of sync with the library linked to binaries: github.com/gogo/protobuf@v1.2.1
2020-10-08 19:52:27 +02:00
Jingyi Hu 2c66612e0e
Merge pull request #12339 from ptabor/202009027-module-tests
Modularization: Establish 'testing' module (integration, functional, e2e)
2020-10-08 09:25:57 -07:00
Piotr Tabor f67956cb7a clientv3: Expose clientv3/examples close to the code.
Many of the tests had missing '// Output:' comment, so were not
runnable. They required fining.
2020-10-08 14:27:32 +02:00
Piotr Tabor dd45d04b2d clientv3/concurrency: Expose examples close to the source-code. 2020-10-07 15:46:56 +02:00
Piotr Tabor c5ccebf792 tests/integration: Simplify the testMain for examples.
We introduce a LazyCluster abstraction (instead of copy-pasted logic)
that makes clusters to be created only if there are runnable tests
in need for the infrastructure.
2020-10-07 15:42:35 +02:00
Piotr Tabor 73b92fe688 tests: Make examples (for not client) to be both: documentation and integration-runnable
This CL tries to connect 2 objectives:
  - Examples should be close (the same package) to the original code,
    such that they can participate in documentation.
  - Examples should be runnable - such that they are not getting out of
    sync with underlying API/implementation.

In case of etcd-client, the examples are assuming running 'integration'
style, i.e. thay do connect to fully functional etcd-server.
That would lead to a cyclic dependencies between modules:
  - server depends on client (as client need to be lightweight)
  - client (for test purposes) depend on server.
Go modules does not allow to distingush testing dependency from
prod-code dependency.

Thus to meet the objective:
  - The examples are getting executed within testing/integration packages against real etcd
  - The examples are symlinked to 'unit' tests, such that they included in documentation.
  - Long-term the unit examples should get rewritten to use 'mocks' instead of real integration tests.
2020-10-07 15:38:40 +02:00
Piotr Tabor 313087f8c5 ./test,./scripts: Update go.sum and bill-of-materials generation logic (and refresh bom). 2020-10-07 15:38:39 +02:00
Piotr Tabor 9866c7e8ff .words: Expanded and resorted .words dictionary file.
Should fail following goword complains:
```
clientv3/config.go.48: // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). (spell: MaxRequestBytes -> ?)
clientv3/config.go.55: // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). (spell: MaxRequestBytes -> ?)
clientv3/leasing/doc.go.15: // Package leasing serves linearizable reads from a local cache by acquiring (spell: linearizable -> infeasible?)
clientv3/op.go.413: // it's linearizable. Serializable requests are better for lower latency (spell: linearizable -> infeasible?)
clientv3/retry.go.49: // an obvious server-side error (e.g. rpctypes.ErrRequestTooLarge). (spell: ErrRequestTooLarge -> Erectile?)
```
2020-10-07 15:38:39 +02:00
Piotr Tabor 7886ec8574 test: Modules: PASSES="integration" ./test understand new file locations 2020-10-07 15:38:39 +02:00
Piotr Tabor be4e8b7013 integration/fixtures: Move the 'tests/integration/fixtures' directory up and update references.
I moved the files up as they are shared between e2e & integrational tests.
2020-10-07 15:38:28 +02:00
Piotr Tabor bb9703820c tests/integration: Move of naming/snapshot clientv3 tests (and yaml reference)
path change in clientv3/yaml/config_test

git mv clientv3/naming/grpc_test.go         tests/integration/clientv3/grpc_test.go
git mv clientv3/snapshot/*_test.go          tests/integration/snapshot
git mv clientv3/{main_test.go,example_*.go} tests/integration/clientv3/examples/
2020-10-07 15:37:24 +02:00
Piotr Tabor ffd4d5173c tests/mod.go: Update of go.mod after move of integration tests. 2020-10-07 15:37:24 +02:00
Piotr Tabor b27b17b44c tests/functional: Mechanical rename of imports etcd/v3/integration/ -> etcd/tests/v3/integration/... 2020-10-07 15:37:21 +02:00
Piotr Tabor 3153038ffb tests/integration: Moving integration tests to tests/integration directory
git mv integration ./tests

git mv client/integration/* ./tests/integration/client
git mv clientv3/integration/* ./tests/integration/clientv3
git mv client/example_keys_test.go client/main_test.go tests/integration/client/examples
git mv clientv3/concurrency/*_test.go tests/integration/clientv3/concurrency

git mv etcdserver/api/v2store/store_v2v3_test.go etcdserver/api/v2v3/*_test.go tests/integration/v2store
git mv tests/integration/v2store/store_v2v3_test.go tests/integration/v2store/store_v2v3.go
git mv tests/integration/v2store/store_test.go tests/integration/v2store/store_v2v3_test.go
git mv etcdserver/api/v2store/store_test.go tests/integration/v2store
git mv etcdserver/api/v2store/store_v2_test.go tests/integration/v2store

git mv proxy/grpcproxy/*_test.go tests/integration/proxy/grpcproxy

git mv ./clientv3/snapshot/testdata ./clientv3/snapshot/*_test.go ./tests/integration/snapshot
2020-10-07 15:36:21 +02:00
Piotr Tabor b382429d01 tests: Move functional tests to 'tests' module.
Tested with:

PASSES="fmt functional unit" ./test
make build-docker-functional
2020-10-07 15:09:26 +02:00
Piotr Tabor 8907b146d4 tests/functional: Mechanical rename of imports etcd/v3/functional/ -> etcd/tests/v3/functional/...
% find ./ -name "*.go" | xargs sed -i "s|go.etcd.io/etcd/v3/functional/agent|go.etcd.io/etcd/tests/v3/functional/agent|g"
% find ./ -name "*.go" | xargs sed -i "s|go.etcd.io/etcd/v3/functional/runner|go.etcd.io/etcd/tests/v3/functional/runner|g"
% find ./ -name "*.go" | xargs sed -i "s|go.etcd.io/etcd/v3/functional/tester|go.etcd.io/etcd/tests/v3/functional/tester|g"
% find ./ -name "*.go" | xargs sed -i "s|go.etcd.io/etcd/v3/functional/rpcpb|go.etcd.io/etcd/tests/v3/functional/rpcpb|g"
2020-10-07 15:09:12 +02:00
Piotr Tabor 69254d8cf8 functional,tests: git mv functional tests/
Modularization: Mechanical move of "functional" directory into tests module using:

% git mv functional tests/
2020-10-07 15:03:51 +02:00
Piotr Tabor 4fb48b7c14 tests: Estabilishing module for tests
For now it contains only e2e tests, but integration & functional will follow.
2020-10-07 15:03:51 +02:00
Jingyi Hu 0aab02e7b5
Merge pull request #12367 from ptabor/20201005-api2client
Modularization: Move dependencies of client (protos, version) to api/ module
2020-10-07 05:56:11 -07:00
Piotr Tabor 997961ebfd bom: Update bill of materials to reflect the new module. 2020-10-06 12:28:40 +02:00
Piotr Tabor ec3026fdc9 *: Run ./scripts/genproto.sh (protoc 3.12.3) after proto file moves.
The changed blobs are consequences of proto-descriptors changing as a
result of file moves.
2020-10-06 11:57:19 +02:00
Piotr Tabor 28f2b07623 *: Update references to code moved to the api/ dir.
Follow up to file-moves done in the previous commit.

The commit contains purely mechanical consequences of execution (apart
of scripts/genproto.sh):

  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/api/v3rpc/rpctypes|v3/api/v3rpc/rpctypes|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/version|v3/api/version|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/mvcc/mvccpb|v3/api/mvccpb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/etcdserverpb|v3/api/etcdserverpb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/api/membership/membershippb|v3/api/membershippb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/auth/authpb|v3/api/authpb|g'

  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/mvcc/mvccpb/kv.proto|/api/mvccpb/kv.proto|g'
  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/auth/authpb/auth.proto|/api/authpb/auth.proto|g'
  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/etcdserver/api/membership/membershippb/membership.proto|/api/membershippb/membership.proto|g'

  I also modified manually paths in scripts/genproto.sh.

  % go fmt ./...
2020-10-06 11:56:16 +02:00
Piotr Tabor 2edb08642c api: Make api/ a module that will contain proto-definitions.
The module is supposed to contain minimal set of files that establish
public etcd server API. In particular client libraries for etcd built in
different languages might want to depend on this file.
2020-10-06 11:54:50 +02:00
Piotr Tabor 389642dd16 client: Move client specific code (protos, version) to api/
client: Move client specific code (protos, version) to the api/
directory. Thanks to this change /client directory will not need to depend on
the server code. In next commits we make "/api" a module on its own.

Mechanical consequences of execution:

% git mv version/version.go api/version
% git mv etcdserver/api/v3rpc/rpctypes api/v3rpc
% git mv mvcc/mvccpb api/
% git mv etcdserver/etcdserverpb api/
% git mv auth/authpb api/
% git mv etcdserver/api/membership/membershippb api/
2020-10-06 11:53:36 +02:00
Sahdev Zala 7bd956fa2b
Merge pull request #12366 from guusvw/fix-yaml-indention-doc
the example alert file had a wrong indentation
2020-10-05 14:08:12 -04:00
Guus van Weelden 985d4cffc4
Documentation: the example alert file had a wrong indentation
Signed-off-by: Guus van Weelden <guus.vanweelden@moia.io>
2020-10-05 18:11:21 +02:00
Sahdev Zala 0693e2b4df
Merge pull request #12355 from cfc4n/changelog_gettoken
CHANGELOG: update for #12165 , #12264 .
2020-10-05 11:14:09 -04:00
Gyuho Lee fdb3f89730
Merge pull request #12362 from ptabor/20201001-deflake-unit-race
Fix "race" - auth unit tests leaking goroutines
2020-10-04 20:47:52 -07:00
Piotr Tabor 97820f1c6e integration: Fix flakes of TestV3WatchRestoreSnapshotUnsync
```
```

The flakes manifested as:
```
--- FAIL: TestV3WatchRestoreSnapshotUnsync (3.59s)
    v3_watch_restore_test.go:82: inflight snapshot sends expected 0 or 1, got ""
FAIL
coverage: 55.2% of statements
FAIL	go.etcd.io/etcd/v3/integration	3.646s
FAIL
```

The root reason is that all the SnapMsg processing happends on both ends
(leader, follower) assynchronously in goroutines, e.g. on Fifo schedule
within EtcdServer.run, so when we observe through metrics, we don't
know whether it finised (or even got started).

Idally we should have EtcdServer.Drain() call that exits when the server
processed or internal 'queues' and is idle.
2020-10-03 19:39:08 +02:00