Граф коммитов

56 Коммитов

Автор SHA1 Сообщение Дата
Matt Lord 770e06f327
Migrate ACL package to pflag (#11392)
* Move acl package to pflag

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Stragglers

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Gofmt after GH merge conflict resolution

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Merge in new vtbackup work

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Address linter errors:
context-as-argument: context.Context should be the first parameter of a function (revive)

Signed-off-by: Matt Lord <mattalord@gmail.com>

Signed-off-by: Matt Lord <mattalord@gmail.com>
2022-09-29 13:40:27 -04:00
Harshit Gangal 5394719517
vtgate pflags migration (#11318)
* [go/cmd/vtgate] migrate to pflags

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* [go/vt/vtgate/vtgateconn] migrate to pflags

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* fix test

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* [go/vt/vtgate] migrate to pflags

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* move to non pointer

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* change test flag usage

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* update the test expectation for help output

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* addressed review comments

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* make vtgateprotcol flag variable as private

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

* fix test usage

Signed-off-by: Harshit Gangal <harshit@planetscale.com>

Signed-off-by: Harshit Gangal <harshit@planetscale.com>
2022-09-26 19:35:22 +05:30
Rohit Nayak bb479cb0df
[cli] Migrate cmd/vtclient and cmd/vttablet from flag to pflag (#11349)
* Migrate vtclient

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Migrate cmd/vttablet

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
2022-09-26 12:17:17 +05:30
Andrew Mason f0d2d4610d
[cli] [servenv] Migrate `--mysql_server_version` to pflag (#11190)
* [sqlparser] Use interoperable flag.Parsed function

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [cli] [servenv] Migrate `--mysql_server_version` flag to pflag

Closes #11144.

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* no mysql_server_version for vtorc

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-09-09 11:29:31 -04:00
Andrew Mason 39ee44f132
[cli] [grpccommon] Migrate flags to `pflag` (#11122)
Closes #10807.

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-08-31 06:29:02 -04:00
Andrew Mason 6596b4645c
[cli] [logutil] Migrate flags defined in `go/vt/logutil` to `pflag` (#11044)
* [internal/flag] Add interoperable _flag.Lookup helper function

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [logutil] Migrate flag definitions to pflag, install on all servenv-compliant binaries

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [go/cmd/*] Ensure all non-servenv compliant entrypoints register logutil flags

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [endtoend] fix test data

Signed-off-by: Andrew Mason <andrew@planetscale.com>

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-08-19 15:47:31 -04:00
Andrew Mason d1a88b3038
[log] Migrate `go/vt/log` flags to `pflag` (#11036)
* [log] Migrate flags to pflag

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* WIP: moving vttestserver over

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Migrate all non-servenv commands to register log flags manually

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vttestserver] handle flags with care

Signed-off-by: Andrew Mason <andrew@planetscale.com>

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-08-19 06:37:34 -04:00
Andrew Mason c3f4a998b2
[cmd/*] Switch to pflag for all CLI flag parsing (#10619)
* Switch to `pflag` for all parsing

This transparently swaps the cli parsing library used by `internal/flag`
from the standard library `flag` package to `spf13/pflag`.

It also introduces hook points for packages throughout the vitess codebase
to register their flags for either all commands using `servenv` or a
particular subset of commands. This allows these packages to continue to
define their flag variables in a package-private way, but without
polluting the global flagset.

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Workaround exit code difference between stdlib `flag` and `pflag`

tl;dr stdlib `flag` has [this][1] and `pflag` does not

[1]: dcf0929de6

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* adjust test data for difference in spacing between pflag/stdflag

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* update lingering legacy flag tests

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Update vtgate/tabletgateway.go to use new interface to isolate flags, update test data

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* update flags in java test code

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-07-25 15:12:09 -04:00
Vicent Marti 8de235531d all: gofmt -w -r 'interface{} -> any' src
Signed-off-by: Vicent Marti <vmg@strn.cat>
2022-03-22 09:39:55 +01:00
Andrew Mason 0fb472e99d
[VEP-4, phase 1] Flag cleanup in `go/cmd` (#9896)
* [vttestserver] tidy imports

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vttestserver] fix flags

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vttlstest] fix flags in usage message

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtclient] fix flags

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vttablet] tidy imports

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vttablet] fix flags in error messages

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [mysqlctl] fix flags in usage strings

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtbackup] fix flags in error strings

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtbench] fix flags in example comments

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtclient] fix flags in usage strings

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtexplain] fix flags in usage

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* [vtctldclient] fix flags and some usages while here

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Need to update tests in vt/vttest as well for tests to pass

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* No double dash needed for `vtctlclient`, only for `vtctl` directly, apparently

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-03-17 17:09:14 -04:00
Andrew Mason 8fde81bc42
[VEP-4, phase 1] Flag Deprecation Warnings (#9733)
* Add helper function to issue deprecation warnings when parsing flags

This package is internal, and extremely temporary. After the
necessary backwards-compatability deprecation cycle to switch to
`pflag`, will be removed.

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Update `cmd` callsites that don't parse via `servenv` to use deprecation-aware parser

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Override `Usage` func to show flags with double-dashes in `-h` output

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Extract and rework the deprecation warning text, plus a little cleaner structure

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Fixup import ordering for `context` while I'm here

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Handle positional arguments to filter out the double-dash for backwards compatibility

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Refactor to support subflag usages and custom usage funcs

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Add ability to filter out certain flags from the Usage

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Documentation for SetUsage nonsense

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Override custom Usages, preserving intended effects

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Special consideration for v1 reshard workflow cli

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Update flags in tests

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Filter out double-dash separator when running `vtctl`/`vtctlclient` <= v13.0.0

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* Add release notes for CLI deprecations with advice

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-03-08 14:27:31 -08:00
Andrew Mason e4fef2574e Fix more errcheck lints
Signed-off-by: Andrew Mason <amason@slack-corp.com>
2021-08-26 15:26:51 -04:00
deepthi a49702d9f9 more master->primary changes in docs, tests, functions and variables.
Use new flags for vtctl commands.

Signed-off-by: deepthi <deepthi@planetscale.com>
2021-08-10 19:52:24 -07:00
Aditya Sharma 47611bca39 goimports -local vitess.io/vitess -w .
Signed-off-by: Aditya Sharma <git@adi.run>
2021-01-04 18:27:04 -05:00
yuxiaobo 03e83d6c30 add license in /go file
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-10-21 22:30:02 +08:00
Toliver Jue ad339533f3 fix race condition
Signed-off-by: Toliver Jue <toliver@planetscale.com>
2019-08-19 12:23:18 +09:00
Toliver Jue 4128986b86 vtclient: Add sequential id generation and throttling
Signed-off-by: Toliver Jue <toliver@planetscale.com>
2019-06-18 09:00:00 +07:00
Sugu Sougoumarane f04d40552c consistent lookup: fix stray tests
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2019-05-08 20:04:07 -07:00
Andres Taylor 98d0428d51 Clean up of tracing
* Extracted the opentracing wrapper to it's own file
 * Commented all the public methods
 * gofmt/goimports
 * Made sure the two interceptor builders are similar

Signed-off-by: Andres Taylor <antaylor@squareup.com>
2019-04-25 15:22:14 +02:00
Andres Taylor 224b905c30 Start tracing after flags are parsed
Signed-off-by: Andres Taylor <antaylor@squareup.com>
2019-04-18 12:03:13 +02:00
Andres Taylor 3afcbbe34c Update copyright holders
Signed-off-by: Andres Taylor <antaylor@squareup.com>
2019-04-14 10:10:20 +02:00
Andres Taylor cdea8585f9 Move out start of tracing to plugin files
Signed-off-by: Andres Taylor <antaylor@squareup.com>
2019-03-29 09:08:59 +01:00
Andres Taylor 4c4bf8d884 Start tracing when starting processes
Signed-off-by: Andres Taylor <antaylor@squareup.com>
2019-03-27 16:51:17 +01:00
deepthi c858a37c21 cmd package
Signed-off-by: deepthi <deepthi@planetscale.com>
2019-03-07 11:13:54 -08:00
David Weitzman e6b1e31439 Factor out glog references for ease of dropping in an adapter to a different logging library.
Note: This is the revert of a temporary revert and has the same effect
as the original PR: https://github.com/vitessio/vitess/pull/3830

Revert "Revert "Factor out glog references""

This reverts commit 246e2898d2.

Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-04-20 19:40:15 -07:00
Michael Berlin 246e2898d2 Revert "Factor out glog references"
Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-20 16:44:06 -07:00
David Weitzman b0cedf1b09 Factor out glog references for ease of dropping in an adapter to a different logging library.
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-04-17 08:56:51 -07:00
Anthony Yeh 6914580ad5
Rewrite imports to new custom URL.
This commit consists only of the changes from running the following:

```
find go -name '*.go' | xargs -n 10 -- sed -i -r -e \
  's,"github.com/youtube/vitess/go/,"vitess.io/vitess/go/,'
```
2018-02-27 12:00:33 -08:00
Sugu Sougoumarane b0395798e6 vitessdriver: switch to go1.8
Issue #2681
We still can't get rid of the legacy 1.7 functions because of how
interfaces work. However, I assume that database/sql won't use them
if it finds the newer 'Context' functions in the driver.

Also, go1.9 has allowed us to implement support for custom types.
We still need to exploit this flexibility to add support for
unsigned and other exotic MySQL types.
2017-12-04 11:04:54 -08:00
Alain Jobart bb0998c031 Switching vtclient test to new test env.
That way it's using a random port, not always the same one, and doesn't
conflict with other tests.

Also adding a helper method to vttest to specify both schemas.
2017-12-03 13:45:12 -08:00
Janne Kulmala 739b4f4f48 vtclient: Prevent crash when a single query has an error 2017-08-11 17:20:46 +02:00
Janne Kulmala cce36606de vtclient: Feature to generate queries with random IDs
When --max_random_id > --min_random_id, for each query, a random number is
generated in [min_random_id, max_random_id) and attached to the end of
the bind variables.
2017-08-08 17:34:10 +02:00
Janne Kulmala 42039dde24 vtclient: Allow running non-DML queries repeatedly
Print summary when count > 1.

BUG=38256611
2017-08-08 17:28:06 +02:00
Bryan Beaudreault c26e7da0b5 add new vterrors.Wrap and vterrors.Wrapf. change all fmt.Errorf calls in route to use these, to avoid losing existing vterror context from tabletserver 2017-08-07 16:40:57 -04:00
Sugu Sougoumarane 7af23e1dde license: BSD->Apache v2.0
Please refer to #2694 and #2670 for motivation and reasoning for
this change.

I've tried to follow best practice in inserting the copyright
headers. In other open source projects, not all files carry
the notice. For example documentation doesn't. I've followed
similar ground rules.

I did not change the php because there is a separate LICENSE
file there by Pixel Federation. We'll first need to notify
them our intent before changing anything there.

As for the presubmit check, it's going to be non-trivial
because of the number of exceptions, like file types,
directories and generated code. So, it will have to be
a separate project.
2017-05-06 00:38:56 -07:00
Sugu Sougoumarane ea12c8f0f6 V3: new session-based protocol
This addresses #2723.

This change is essentially a new protocol for V3. Although
backward compatible, it changes the connection model.
Basically, the newer V3 features will work only if you used
the new protocol.

The new model deprecates keyspace_shard, tablet_type and options
from ExecuteRequest and moves them into the Session. This means
that the Session is generally not empty, and may be updated
by any call to Execute or ExecuteBatch, even if the statements are
not transactional. Consequently, transactional methods like Begin,
etc. are deprecated in favor of Execute("begin").

Transaction modes will now be supported by new `SET` syntax, which
will correspondingly update the Session variable.

This also makes a connection that contains a session non-multiplexable.
We'll need to resolve whether it's still worth exposing this flexibility
to the clients, and if so, how.

For now, I've updated the Go driver to use the "modern" protocol.
However, the low level rpc (Impl) continues to support the older
functions like Begin, etc. This allows us to test the legacy
functionality.

All other clients: Python, PHP and Java are currently unchanged.

Given that this is a major protocol change, it hints at a 3.0,
but the changes are 2.1 compatible with the following exceptions:

* Go driver uses the new protocol.
* vtclient binary requires `-target` instead of `-tablet-type`, etc.

All tests are passing including PHP & Java clients. In terms
of upgrade:

* PHP and Java can be upgraded by just updating the code.
* Python will probably require a brand new library. The existing
  vtdb contains way too much baggage, and it may not be worth
  retrofitting this new incompatible protocol onto what's
  currently there. I'm looking for a name. `vtdb2`, `vitessdb`?
2017-04-28 13:08:44 -07:00
Michael Berlin fa98349ea3 vtclient: Log number of errors broken down by error code.
Also log the first error per error code.

I've also changed the behavior of the multi DML mode to continue executing more queries and not returning early if an error occurs.
2017-03-28 18:04:21 -07:00
Michael Berlin fe194747d7 vtclient: Add flags -parallel and -count to run queries repeatedly and in parallel.
This is useful for simple load testing.
2017-03-28 18:04:21 -07:00
Michael Berlin d6a6a0ffb4 vtclient: Add unit test based on "vttest" package.
vttest will start an actual MySQL instance and the vtcombo binary.

Then the test runs various queries and verifies that the number of rows affected is correct.

Due to the external processes, this test takes ~8 seconds to run.

This required several vtclient changes:
- return error instead of using exit.Return(1)
- enhanced "results" struct and always return it now
- moved DML logic into separate function and changed it to return a "results" as well
- moved non-DML logic into a function as well
2017-03-28 18:04:21 -07:00
Michael Berlin 18df41f909 vtclient: Replaced custom isDml() function with new sqlparser function. 2017-03-28 17:36:36 -07:00
Michael Berlin 303d15307d vtclient: Add examples in usage. 2017-03-28 17:36:36 -07:00
Michael Berlin aa3f2200f5 vtclient: Fail if more than one positional argument is specified.
Before this change, a user could provide flags *after* the query and these would be ignored by the code. Now, the user gets an error and can fix the call.
2017-03-28 17:36:36 -07:00
Michael Berlin 25880fa58b vtclient: Fix execution of DMLs.
The transaction object was not used. This is probably a regression which
was introduced with the Go 1.8 vitessdriver changes.
2017-03-28 17:36:36 -07:00
Sugu Sougoumarane bef31d6405 go1.8 compliant functions in vitessdriver
I've left out the row support functions because most of them are
not supported by the protocol. The most important changes
are supported: contexts and named arguments.

* Deleted the deprecated shard specific connection support.
* Built go1.8, fixed compilation errors and added tests.
* Fixed documentation that was still stating support for v1 API.
* Fixed custom_sharding test that was relying on v1 API.
* Doc comments updated to explain isolation levels and named args.
* Code review comments addressed.
2016-11-04 13:28:56 -07:00
Alain Jobart 7da63bd2ed Adding tests for vtclient v3.
And fixing the bug it uncovered. No tests = bug for sure.
2016-05-24 11:49:20 -07:00
Anthony Yeh 23f91535e5 Make JSON field names for QueryResult consistent with protobuf. 2016-02-25 15:22:41 -08:00
Anthony Yeh f92686a2a4 Print human-readable tables for CLI queries.
The table output is similar to the `mysql` CLI.
2016-02-25 15:01:33 -08:00
Michael Berlin 5c44fbda29 vtclient: Pass --vtgate_protocol into Go SQL driver configuration.
Otherwise tests will always be executed with "grpc" driver. This fails when a BSON RPC vtgate is used in the tests.
2015-12-13 20:16:33 -08:00
Michael Berlin a744f640ea vitessdriver: Provide helper functions to open database.
Updated current users vtclient and client.go accordingly.
2015-12-09 20:50:34 -08:00
Michael Berlin dfbb412973 vtclient: Fix go lint error ("ID" must be all caps). 2015-12-08 17:20:03 -08:00