mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 00:22:07 +00:00
pt-galera-log-explainer: whois regression tests
This commit is contained in:
@@ -137,6 +137,28 @@ func TestMain(t *testing.T) {
|
||||
cmd: []string{"list", "--all", "--custom-regexes=Page cleaner took [0-9]*ms to flush 2000=;use of .*pxc_strict_mode=", "--no-color"},
|
||||
path: "tests/logs/merge_rotated_daily/node1.20230315.log",
|
||||
},
|
||||
{
|
||||
name: "operator_ambiguous_ips_whois_cluster1-1",
|
||||
cmd: []string{"whois", "cluster1-1", "--pxc-operator"},
|
||||
path: "tests/logs/operator_ambiguous_ips/*",
|
||||
},
|
||||
|
||||
{
|
||||
name: "operator_ambiguous_ips_whois_e2239bca-93a3",
|
||||
cmd: []string{"whois", "e2239bca-93a3", "--pxc-operator"},
|
||||
path: "tests/logs/operator_ambiguous_ips/*",
|
||||
},
|
||||
{ // symlink to the output of the test above, should be identical
|
||||
name: "operator_ambiguous_ips_whois_e2239bca-256c-11ee-93a3-e23704b1e880",
|
||||
cmd: []string{"whois", "e2239bca-256c-11ee-93a3-e23704b1e880", "--pxc-operator"},
|
||||
path: "tests/logs/operator_ambiguous_ips/*",
|
||||
},
|
||||
|
||||
{
|
||||
name: "operator_ambiguous_ips_whois_10.16.27.98",
|
||||
cmd: []string{"whois", "10.16.27.98", "--pxc-operator"},
|
||||
path: "tests/logs/operator_ambiguous_ips/*",
|
||||
},
|
||||
}
|
||||
|
||||
TESTS:
|
||||
|
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"10.16.27.98": {
|
||||
"SubNodes": {
|
||||
"nodename": {
|
||||
"cluster1-1": {
|
||||
"Timestamp": "0001-01-01T00:00:00Z",
|
||||
"SubNodes": {
|
||||
"ip": {
|
||||
"10.16.27.149": {
|
||||
"Timestamp": "2023-05-21T00:55:34.59855Z"
|
||||
},
|
||||
"10.16.27.195": {
|
||||
"Timestamp": "2023-05-10T09:06:21.290854Z"
|
||||
},
|
||||
"10.16.27.203": {
|
||||
"Timestamp": "2023-05-21T01:21:12.237121Z"
|
||||
},
|
||||
"10.16.27.67": {
|
||||
"Timestamp": "2023-05-10T11:43:19.838842Z"
|
||||
},
|
||||
"10.16.27.93": {
|
||||
"Timestamp": "2023-05-10T10:49:15.965568Z"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"09afeef6-a69d": {
|
||||
"Timestamp": "2023-05-10T09:06:21.310966Z"
|
||||
},
|
||||
"106cd5a8-8e1c": {
|
||||
"Timestamp": "2023-05-10T09:42:20.096709Z"
|
||||
},
|
||||
"4ca2c784-a878": {
|
||||
"Timestamp": "2023-05-21T00:55:34.619148Z"
|
||||
},
|
||||
"6a146d09-8747": {
|
||||
"Timestamp": "2023-05-10T10:49:15.98352Z"
|
||||
},
|
||||
"e123e2f3-ace4": {
|
||||
"Timestamp": "2023-05-21T01:21:12.258721Z"
|
||||
},
|
||||
"e123e2f3-ace5": {
|
||||
"Timestamp": "2023-05-24T09:08:00.784586Z"
|
||||
},
|
||||
"f7946b60-bf31": {
|
||||
"Timestamp": "2023-05-10T11:43:19.859843Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"215101e1-b61d": {
|
||||
"Timestamp": "2023-05-16T03:01:59.175607Z"
|
||||
},
|
||||
"250ac3d5-8380": {
|
||||
"Timestamp": "2023-05-18T13:15:19.825195Z"
|
||||
},
|
||||
"2cc76c37-becc": {
|
||||
"Timestamp": "2023-05-10T11:51:58.610014Z"
|
||||
},
|
||||
"2cc76c37-becd": {
|
||||
"Timestamp": "2023-05-12T19:13:56.828375Z"
|
||||
},
|
||||
"2cc76c37-bece": {
|
||||
"Timestamp": "2023-05-12T19:29:34.102395Z"
|
||||
},
|
||||
"2cc76c37-becf": {
|
||||
"Timestamp": "2023-05-16T02:56:58.102204Z"
|
||||
},
|
||||
"3c016ef3-af4c": {
|
||||
"Timestamp": "2023-05-18T08:51:06.974925Z"
|
||||
},
|
||||
"5fd057e4-bab5": {
|
||||
"Timestamp": "2023-05-18T11:15:16.987418Z"
|
||||
},
|
||||
"66e2b7bf-8000": {
|
||||
"Timestamp": "2023-05-29T07:20:31.719983Z"
|
||||
},
|
||||
"70a8263e-989f": {
|
||||
"Timestamp": "2023-05-18T13:17:26.686853Z"
|
||||
},
|
||||
"7a3b782e-96c0": {
|
||||
"Timestamp": "2023-05-18T14:00:39.734544Z"
|
||||
},
|
||||
"87e7065b-bf25": {
|
||||
"Timestamp": "2023-05-16T03:04:51.285176Z"
|
||||
},
|
||||
"87e7065b-bf26": {
|
||||
"Timestamp": "2023-05-16T07:52:26.432272Z"
|
||||
},
|
||||
"8e6f32b6-bf89": {
|
||||
"Timestamp": "2023-05-28T08:55:52.689854Z",
|
||||
"SubNodes": {
|
||||
"nodename": {
|
||||
"unspecified": {
|
||||
"Timestamp": "2023-05-29T07:16:49.686673Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"96435e8a-bab8": {
|
||||
"Timestamp": "2023-05-16T02:58:05.880842Z"
|
||||
},
|
||||
"c943db75-9035": {
|
||||
"Timestamp": "2023-05-25T04:36:13.482715Z"
|
||||
},
|
||||
"c943db75-9036": {
|
||||
"Timestamp": "2023-05-28T08:23:24.701198Z"
|
||||
},
|
||||
"d0e11ff4-be29": {
|
||||
"Timestamp": "2023-05-16T02:59:44.222891Z"
|
||||
},
|
||||
"e2239bca-93a3": {
|
||||
"Timestamp": "2023-05-18T13:13:27.582217Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"cluster1-1": {
|
||||
"SubNodes": {
|
||||
"ip": {
|
||||
"10.16.27.149": {
|
||||
"Timestamp": "2023-05-21T00:55:34.59855Z"
|
||||
},
|
||||
"10.16.27.195": {
|
||||
"Timestamp": "2023-05-10T09:06:21.290854Z"
|
||||
},
|
||||
"10.16.27.203": {
|
||||
"Timestamp": "2023-05-21T01:21:12.237121Z"
|
||||
},
|
||||
"10.16.27.67": {
|
||||
"Timestamp": "2023-05-10T11:43:19.838842Z"
|
||||
},
|
||||
"10.16.27.93": {
|
||||
"Timestamp": "2023-05-10T10:49:15.965568Z"
|
||||
},
|
||||
"10.16.27.98": {
|
||||
"Timestamp": "0001-01-01T00:00:00Z"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"09afeef6-a69d": {
|
||||
"Timestamp": "2023-05-10T09:06:21.310966Z"
|
||||
},
|
||||
"106cd5a8-8e1c": {
|
||||
"Timestamp": "2023-05-10T09:42:20.096709Z"
|
||||
},
|
||||
"215101e1-b61d": {
|
||||
"Timestamp": "2023-05-16T03:01:59.175607Z"
|
||||
},
|
||||
"250ac3d5-8380": {
|
||||
"Timestamp": "2023-05-18T13:15:19.825195Z"
|
||||
},
|
||||
"2cc76c37-becc": {
|
||||
"Timestamp": "2023-05-10T11:51:58.610014Z"
|
||||
},
|
||||
"2cc76c37-becd": {
|
||||
"Timestamp": "2023-05-12T19:13:56.828375Z"
|
||||
},
|
||||
"2cc76c37-bece": {
|
||||
"Timestamp": "2023-05-12T19:29:34.102395Z"
|
||||
},
|
||||
"2cc76c37-becf": {
|
||||
"Timestamp": "2023-05-16T02:56:58.102204Z"
|
||||
},
|
||||
"3c016ef3-af4c": {
|
||||
"Timestamp": "2023-05-18T08:51:06.97503Z"
|
||||
},
|
||||
"4ca2c784-a878": {
|
||||
"Timestamp": "2023-05-21T00:55:34.619148Z"
|
||||
},
|
||||
"5fd057e4-bab5": {
|
||||
"Timestamp": "2023-05-18T11:15:16.987418Z"
|
||||
},
|
||||
"66e2b7bf-8000": {
|
||||
"Timestamp": "2023-05-29T07:20:31.719983Z"
|
||||
},
|
||||
"6a146d09-8747": {
|
||||
"Timestamp": "2023-05-10T10:49:15.98352Z"
|
||||
},
|
||||
"70a8263e-989f": {
|
||||
"Timestamp": "2023-05-18T13:17:26.686853Z"
|
||||
},
|
||||
"7a3b782e-96c0": {
|
||||
"Timestamp": "2023-05-18T14:00:39.734694Z"
|
||||
},
|
||||
"87e7065b-bf25": {
|
||||
"Timestamp": "2023-05-16T03:04:51.285176Z"
|
||||
},
|
||||
"87e7065b-bf26": {
|
||||
"Timestamp": "2023-05-16T07:52:26.432272Z"
|
||||
},
|
||||
"8e6f32b6-bf89": {
|
||||
"Timestamp": "2023-05-28T08:55:54.185342Z",
|
||||
"SubNodes": {
|
||||
"nodename": {
|
||||
"unspecified": {
|
||||
"Timestamp": "2023-05-29T07:16:49.686673Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"96435e8a-bab8": {
|
||||
"Timestamp": "2023-05-16T02:58:05.880842Z"
|
||||
},
|
||||
"c943db75-9035": {
|
||||
"Timestamp": "2023-05-25T04:36:13.482766Z"
|
||||
},
|
||||
"c943db75-9036": {
|
||||
"Timestamp": "2023-05-28T08:23:24.701198Z"
|
||||
},
|
||||
"d0e11ff4-be29": {
|
||||
"Timestamp": "2023-05-16T02:59:44.222891Z"
|
||||
},
|
||||
"e123e2f3-ace4": {
|
||||
"Timestamp": "2023-05-21T01:21:12.258721Z"
|
||||
},
|
||||
"e123e2f3-ace5": {
|
||||
"Timestamp": "2023-05-24T09:08:00.784586Z"
|
||||
},
|
||||
"e2239bca-93a3": {
|
||||
"Timestamp": "2023-05-18T13:13:27.582217Z"
|
||||
},
|
||||
"f7946b60-bf31": {
|
||||
"Timestamp": "2023-05-10T11:43:19.859843Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
operator_ambiguous_ips_whois_e2239bca-93a3
|
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"e2239bca-93a3": {
|
||||
"SubNodes": {
|
||||
"ip": {
|
||||
"10.16.27.98": {
|
||||
"Timestamp": "2023-05-18T13:13:27.582217Z"
|
||||
}
|
||||
},
|
||||
"nodename": {
|
||||
"cluster1-1": {
|
||||
"Timestamp": "2023-05-18T13:13:27.582217Z",
|
||||
"SubNodes": {
|
||||
"ip": {
|
||||
"10.16.27.149": {
|
||||
"Timestamp": "2023-05-21T00:55:34.59855Z"
|
||||
},
|
||||
"10.16.27.195": {
|
||||
"Timestamp": "2023-05-10T09:06:21.290854Z"
|
||||
},
|
||||
"10.16.27.203": {
|
||||
"Timestamp": "2023-05-21T01:21:12.237121Z"
|
||||
},
|
||||
"10.16.27.67": {
|
||||
"Timestamp": "2023-05-10T11:43:19.838842Z"
|
||||
},
|
||||
"10.16.27.93": {
|
||||
"Timestamp": "2023-05-10T10:49:15.965568Z"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"09afeef6-a69d": {
|
||||
"Timestamp": "2023-05-10T09:06:21.310966Z"
|
||||
},
|
||||
"106cd5a8-8e1c": {
|
||||
"Timestamp": "2023-05-10T09:42:20.096709Z"
|
||||
},
|
||||
"215101e1-b61d": {
|
||||
"Timestamp": "2023-05-16T03:01:59.175607Z"
|
||||
},
|
||||
"250ac3d5-8380": {
|
||||
"Timestamp": "2023-05-18T13:15:19.825195Z"
|
||||
},
|
||||
"2cc76c37-becc": {
|
||||
"Timestamp": "2023-05-10T11:51:58.610014Z"
|
||||
},
|
||||
"2cc76c37-becd": {
|
||||
"Timestamp": "2023-05-12T19:13:56.828375Z"
|
||||
},
|
||||
"2cc76c37-bece": {
|
||||
"Timestamp": "2023-05-12T19:29:34.102395Z"
|
||||
},
|
||||
"2cc76c37-becf": {
|
||||
"Timestamp": "2023-05-16T02:56:58.102204Z"
|
||||
},
|
||||
"3c016ef3-af4c": {
|
||||
"Timestamp": "2023-05-18T08:51:06.97503Z"
|
||||
},
|
||||
"4ca2c784-a878": {
|
||||
"Timestamp": "2023-05-21T00:55:34.619148Z"
|
||||
},
|
||||
"5fd057e4-bab5": {
|
||||
"Timestamp": "2023-05-18T11:15:16.987418Z"
|
||||
},
|
||||
"66e2b7bf-8000": {
|
||||
"Timestamp": "2023-05-29T07:20:31.719983Z"
|
||||
},
|
||||
"6a146d09-8747": {
|
||||
"Timestamp": "2023-05-10T10:49:15.98352Z"
|
||||
},
|
||||
"70a8263e-989f": {
|
||||
"Timestamp": "2023-05-18T13:17:26.686853Z"
|
||||
},
|
||||
"7a3b782e-96c0": {
|
||||
"Timestamp": "2023-05-18T14:00:39.734694Z"
|
||||
},
|
||||
"87e7065b-bf25": {
|
||||
"Timestamp": "2023-05-16T03:04:51.285176Z"
|
||||
},
|
||||
"87e7065b-bf26": {
|
||||
"Timestamp": "2023-05-16T07:52:26.432272Z"
|
||||
},
|
||||
"8e6f32b6-bf89": {
|
||||
"Timestamp": "2023-05-28T08:55:54.185342Z",
|
||||
"SubNodes": {
|
||||
"nodename": {
|
||||
"unspecified": {
|
||||
"Timestamp": "2023-05-29T07:16:49.686673Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"96435e8a-bab8": {
|
||||
"Timestamp": "2023-05-16T02:58:05.880842Z"
|
||||
},
|
||||
"c943db75-9035": {
|
||||
"Timestamp": "2023-05-25T04:36:13.482766Z"
|
||||
},
|
||||
"c943db75-9036": {
|
||||
"Timestamp": "2023-05-28T08:23:24.701198Z"
|
||||
},
|
||||
"d0e11ff4-be29": {
|
||||
"Timestamp": "2023-05-16T02:59:44.222891Z"
|
||||
},
|
||||
"e123e2f3-ace4": {
|
||||
"Timestamp": "2023-05-21T01:21:12.258721Z"
|
||||
},
|
||||
"e123e2f3-ace5": {
|
||||
"Timestamp": "2023-05-24T09:08:00.784586Z"
|
||||
},
|
||||
"f7946b60-bf31": {
|
||||
"Timestamp": "2023-05-10T11:43:19.859843Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,6 +19,12 @@ type WhoisValue struct {
|
||||
|
||||
type subNode map[string]*WhoisNode
|
||||
|
||||
// When initiating recursion, instead of iterating over maps we should iterate over a fixed order of types
|
||||
// maps orders are not guaranteed, and there are multiple paths of identifying information
|
||||
// Forcing the order ultimately helps to provide repeatable output, so it helps with regression tests
|
||||
// It also helps reducing graph depth, as "nodename" will have most of its information linked to it directly
|
||||
var forcedIterationOrder = []string{"nodename", "ip", "uuid"}
|
||||
|
||||
func Whois(search, searchtype string) *WhoisNode {
|
||||
w := &WhoisNode{
|
||||
nodetype: searchtype,
|
||||
@@ -71,6 +77,8 @@ func (n *WhoisNode) GetValueData(search, searchType string) *WhoisValue {
|
||||
if n.nodetype == searchType && search == value {
|
||||
return &valueData
|
||||
}
|
||||
// iterating over subnodes here is fine, as the value we search for should be unique
|
||||
// so the way to access don't have to be forced
|
||||
for _, nextNode := range valueData.SubNodes {
|
||||
if nextNode != nil {
|
||||
if valueData := nextNode.GetValueData(search, searchType); valueData != nil {
|
||||
@@ -93,7 +101,9 @@ func (n *WhoisNode) filter() {
|
||||
}
|
||||
|
||||
for _, valueData := range n.Values {
|
||||
for _, nextNode := range valueData.SubNodes {
|
||||
// see comment on "forcedIterationOrder"
|
||||
for _, nextNodeType := range forcedIterationOrder {
|
||||
nextNode := valueData.SubNodes[nextNodeType]
|
||||
if nextNode != nil {
|
||||
nextNode.filter()
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/regex"
|
||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/translate"
|
||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/types"
|
||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/utils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -58,6 +59,14 @@ func (w *whois) Run() error {
|
||||
}
|
||||
}
|
||||
|
||||
if CLI.Verbosity == types.Debug {
|
||||
out, err := translate.DBToJson()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not dump translation structs to json")
|
||||
}
|
||||
fmt.Println(out)
|
||||
}
|
||||
|
||||
log.Debug().Str("searchType", w.SearchType).Msg("whois searchType")
|
||||
out := translate.Whois(w.Search, w.SearchType)
|
||||
|
||||
|
Reference in New Issue
Block a user