mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
PT-2164 version flag for pt-k8s-debug-collector (#576)
* PT-2164 - pt-k8s-debug-collector does not have version flag Added flag Updated README * PT-2164 - pt-k8s-debug-collector does not have version flag Added test case * PT-2164 version flag for pt-k8s-debug-collector go fmt for src/go/pt-k8s-debug-collector/main.go * PT-2164 version flag for pt-k8s-debug-collector Updated docs/pt-k8s-debug-collector.rst
This commit is contained in:
@@ -122,7 +122,7 @@ Usage
|
||||
|
||||
``pt-k8s-debug-collector <flags>``
|
||||
|
||||
Supported Flags:
|
||||
Supported Flags
|
||||
================
|
||||
|
||||
``--resource``
|
||||
@@ -157,12 +157,18 @@ Path to kubeconfig. Default configuration be used if none specified
|
||||
|
||||
Port to use when collecting database-specific summaries. By default, 3306 will be used for PXC and MySQL, 27017 for MongoDB, and 5432 for PostgreSQL
|
||||
|
||||
``--version``
|
||||
|
||||
Print version info
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
- Installed, configured, and available in PATH ``kubectl``
|
||||
- Installed, configured, and available in PATH ``pt-mysql-summary`` for PXC and MySQL
|
||||
- Installed, configured, and available in PATH ``mysql`` for PXC and MySQL
|
||||
- Installed, configured, and available in PATH ``pt-mongodb-summary`` for MongoDB
|
||||
- Installed, configured, and available in PATH ``psql`` for PostgreSQL
|
||||
|
||||
Known Issues
|
||||
============
|
||||
|
@@ -122,7 +122,7 @@ Usage
|
||||
|
||||
``pt-k8s-debug-collector <flags>``
|
||||
|
||||
Supported Flags:
|
||||
Supported Flags
|
||||
================
|
||||
|
||||
``--resource``
|
||||
@@ -157,12 +157,18 @@ Path to kubeconfig. Default configuration be used if none specified
|
||||
|
||||
Port to use when collecting database-specific summaries. By default, 3306 will be used for PXC and MySQL, 27017 for MongoDB, and 5432 for PostgreSQL
|
||||
|
||||
``--version``
|
||||
|
||||
Print version info
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
- Installed, configured, and available in PATH ``kubectl``
|
||||
- Installed, configured, and available in PATH ``pt-mysql-summary`` for PXC and MySQL
|
||||
- Installed, configured, and available in PATH ``mysql`` for PXC and MySQL
|
||||
- Installed, configured, and available in PATH ``pt-mongodb-summary`` for MongoDB
|
||||
- Installed, configured, and available in PATH ``psql`` for PostgreSQL
|
||||
|
||||
Known Issues
|
||||
============
|
||||
|
@@ -2,26 +2,50 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/percona/percona-toolkit/src/go/pt-k8s-debug-collector/dumper"
|
||||
)
|
||||
|
||||
const (
|
||||
TOOLNAME = "pt-k8s-debug-collector"
|
||||
)
|
||||
|
||||
// We do not set anything here, these variables are defined by the Makefile
|
||||
var (
|
||||
Build string
|
||||
GoVersion string
|
||||
Version string
|
||||
Commit string
|
||||
)
|
||||
|
||||
func main() {
|
||||
namespace := ""
|
||||
resource := ""
|
||||
clusterName := ""
|
||||
kubeconfig := ""
|
||||
forwardport := ""
|
||||
version := false
|
||||
|
||||
flag.StringVar(&namespace, "namespace", "", "Namespace for collecting data. If empty data will be collected from all namespaces")
|
||||
flag.StringVar(&resource, "resource", "none", "Collect data, specific to the resource. Supported values: pxc, psmdb, pg, ps, none")
|
||||
flag.StringVar(&clusterName, "cluster", "", "Cluster name")
|
||||
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to kubeconfig")
|
||||
flag.StringVar(&forwardport, "forwardport", "", "Port to use for port forwarding")
|
||||
flag.BoolVar(&version, "version", false, "Print version")
|
||||
flag.Parse()
|
||||
|
||||
if version {
|
||||
fmt.Println(TOOLNAME)
|
||||
fmt.Printf("Version %s\n", Version)
|
||||
fmt.Printf("Build: %s using %s\n", Build, GoVersion)
|
||||
fmt.Printf("Commit: %s\n", Commit)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if len(clusterName) > 0 {
|
||||
resource += "/" + clusterName
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
"regexp"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
@@ -22,7 +23,7 @@ This test requires:
|
||||
|
||||
You can additionally set option FORWARDPORT if you want to use custom port when testing summaries.
|
||||
|
||||
pt-mysql-summary and pt-mongodb-summary must be in the PATH.
|
||||
pt-mysql-summary, mysql, psql, and pt-mongodb-summary must be in the PATH.
|
||||
|
||||
Since running pt-k8s-debug-collector may take long time run go test with increase timeout:
|
||||
go test -timeout 6000s
|
||||
@@ -158,3 +159,18 @@ func TestResourceOption(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Option --version
|
||||
*/
|
||||
func TestVersionOption(t *testing.T) {
|
||||
out, err := exec.Command("../../../bin/pt-k8s-debug-collector", "--version").Output()
|
||||
if err != nil {
|
||||
t.Errorf("error executing pt-k8s-debug-collector --version: %s", err.Error())
|
||||
}
|
||||
// We are using MustCompile here, because hard-coded RE should not fail
|
||||
re := regexp.MustCompile(TOOLNAME + `\n.*Version \d+\.\d+\.\d+\n`)
|
||||
if !re.Match(out) {
|
||||
t.Errorf("pt-k8s-debug-collector --version returns wrong result:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user