Skip to content

Commit

Permalink
[release-17.0] [ci] add generator for templated flag testdata (#13150) (
Browse files Browse the repository at this point in the history
#13233)

* add generator for templated flag testdata

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

* Apply suggestions from code review

Co-authored-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>

* while loop + variable directory

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

---------

Signed-off-by: Andrew Mason <andrew@planetscale.com>
Co-authored-by: Andrew Mason <andrew@planetscale.com>
Co-authored-by: Andrew Mason <amason@hey.com>
Co-authored-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
4 people committed Jun 5, 2023
1 parent e14f492 commit f58e38a
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export REWRITER=go/vt/sqlparser/rewriter.go
# Since we are not using this Makefile for compilation, limiting parallelism will not increase build time.
.NOTPARALLEL:

.PHONY: all build install test clean unit_test unit_test_cover unit_test_race integration_test proto proto_banner site_test site_integration_test docker_bootstrap docker_test docker_unit_test java_test reshard_tests e2e_test e2e_test_race minimaltools tools generate_ci_workflows
.PHONY: all build install test clean unit_test unit_test_cover unit_test_race integration_test proto proto_banner site_test site_integration_test docker_bootstrap docker_test docker_unit_test java_test reshard_tests e2e_test e2e_test_race minimaltools tools generate_ci_workflows generate-flag-testdata

all: build

Expand Down Expand Up @@ -457,6 +457,9 @@ vtadmin_authz_testgen:
generate_ci_workflows:
cd test && go run ci_workflow_gen.go && cd ..

generate-flag-testdata:
./tools/generate_flag_testdata.sh

release-notes:
go run ./go/tools/release-notes --from "$(FROM)" --to "$(TO)" --version "$(VERSION)" --summary "$(SUMMARY)"

Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/mysqlctl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Global flags:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--db-credentials-file string db credentials file; send SIGHUP to reload this file
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/mysqlctld.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Usage of mysqlctld:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--db-credentials-file string db credentials file; send SIGHUP to reload this file
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtaclcheck.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Usage of vtaclcheck:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
-h, --help display usage and exit
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtbackup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Usage of vtbackup:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtctlclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Usage of vtctlclient:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--datadog-agent-host string host to send spans to. if empty, no tracing will be done
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtctld.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Usage of vtctld:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtexplain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Usage of vtexplain:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--dbname string Optional database target to override normal routing
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtgate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage of vtgate:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtgr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Usage of vtgr:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtorc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Usage of vtorc:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Usage of vttablet:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consolidator-stream-query-size int Configure the stream consolidator query size in bytes. Setting to 0 disables the stream consolidator. (default 2097152)
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vttestserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usage of vttestserver:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
--consul_auth_static_file string JSON File to read the topos/tokens from.
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/zkctl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Usage of zkctl:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
-h, --help display usage and exit
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/zkctld.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Usage of zkctld:
--config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.
--config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn)
--config-name string Name of the config file (without extension) to search for. (default "vtconfig")
--config-path strings Paths to search for config files in. (default [{{.Workdir}}])
--config-path strings Paths to search for config files in. (default [{{ .Workdir }}])
--config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s)
--config-type string Config file type (omit to infer config type from file extension).
-h, --help display usage and exit
Expand Down
21 changes: 21 additions & 0 deletions tools/generate_flag_testdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

DIR="go/flags/endtoend"

templatize_help_text() {
$1 --help 2>&1 | \
sed -e 's/{{/{{ "{{/' \
-e 's/}}/}}" }}/' \
-e 's/Paths to search for config files in. (default .*)/Paths to search for config files in. (default [{{ .Workdir }}])/'
return 0
}

export -f templatize_help_text

while read -r testfile; do
base="${testfile##*/}"
binary="${base%.*}"
templatize_help_text "${binary}" > "${testfile}"
done < <(find "${DIR}" -iname '*.txt')

0 comments on commit f58e38a

Please sign in to comment.