Browse Source

Merge pull request #11109 from vimalk78/tools-fix

tools/etcd-dump-logs: Fixed default values for -entry-type flag
Xiang Li 6 years ago
parent
commit
dc56dfc68f

+ 3 - 3
tools/etcd-dump-logs/expectedoutput/decoder_correctoutputformat.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -26,7 +26,7 @@ term	     index	type	data	decoder_status	decoded_data
   12	        18	norm	ID:13 auth_enable:<> 	ERROR	jhjdcbcejj
   13	        19	norm	ID:14 auth_disable:<> 	ERROR	jhjeiacfjj
   14	        20	norm	ID:15 authenticate:<name:"myname" password:"password" simple_token:"token" > 	OK	jhjfabcfaijajffdgifefafdfeabjhgjfagcgcggffgbfdaajegdfffbfefe
-  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" > 	OK	jhajebddjejajefefafdfecaabjegjfagcgcca
+  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" options:<> > 	OK	jhajebddajjajefefafdfecaabjegjfagcgccaaajj
   16	        22	norm	ID:17 auth_user_delete:<name:"name1" > 	OK	jhaaeaddjgjajefefafdfeca
   17	        23	norm	ID:18 auth_user_get:<name:"name1" > 	OK	jhabfbddjgjajefefafdfeca
   18	        24	norm	ID:19 auth_user_change_password:<name:"name1" password:"pass2" > 	OK	jhacfaddjejajefefafdfecaabjegjfagcgccb
@@ -41,4 +41,4 @@ term	     index	type	data	decoder_status	decoded_data
   27	        33	norm	ID:28 auth_role_revoke_permission:<role:"role3" key:"key" range_end:"rangeend" > 	OK	jhacabdbafjajegbfffcfeccabjcfbfegiaajhgbfafefgfefefefd
   27	        34	norm	???	ERROR	cf
 
-Entry types () count is : 34
+Entry types (Normal,ConfigChange) count is : 34

+ 3 - 3
tools/etcd-dump-logs/expectedoutput/decoder_wrongoutputformat.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -26,7 +26,7 @@ term	     index	type	data	decoder_status	decoded_data
   12	        18	norm	ID:13 auth_enable:<> 	decoder output format is not right, print output anyway	jhjdcbcejj
   13	        19	norm	ID:14 auth_disable:<> 	decoder output format is not right, print output anyway	jhjeiacfjj
   14	        20	norm	ID:15 authenticate:<name:"myname" password:"password" simple_token:"token" > 	decoder output format is not right, print output anyway	jhjfabcfaijajffdgifefafdfeabjhgjfagcgcggffgbfdaajegdfffbfefe
-  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" > 	decoder output format is not right, print output anyway	jhajebddjejajefefafdfecaabjegjfagcgcca
+  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" options:<> > 	decoder output format is not right, print output anyway	jhajebddajjajefefafdfecaabjegjfagcgccaaajj
   16	        22	norm	ID:17 auth_user_delete:<name:"name1" > 	decoder output format is not right, print output anyway	jhaaeaddjgjajefefafdfeca
   17	        23	norm	ID:18 auth_user_get:<name:"name1" > 	decoder output format is not right, print output anyway	jhabfbddjgjajefefafdfeca
   18	        24	norm	ID:19 auth_user_change_password:<name:"name1" password:"pass2" > 	decoder output format is not right, print output anyway	jhacfaddjejajefefafdfecaabjegjfagcgccb
@@ -41,4 +41,4 @@ term	     index	type	data	decoder_status	decoded_data
   27	        33	norm	ID:28 auth_role_revoke_permission:<role:"role3" key:"key" range_end:"rangeend" > 	decoder output format is not right, print output anyway	jhacabdbafjajegbfffcfeccabjcfbfegiaajhgbfafefgfefefefd
   27	        34	norm	???	decoder output format is not right, print output anyway	cf
 
-Entry types () count is : 34
+Entry types (Normal,ConfigChange) count is : 34

+ 3 - 3
tools/etcd-dump-logs/expectedoutput/listAll.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -26,7 +26,7 @@ term	     index	type	data
   12	        18	norm	ID:13 auth_enable:<> 
   13	        19	norm	ID:14 auth_disable:<> 
   14	        20	norm	ID:15 authenticate:<name:"myname" password:"password" simple_token:"token" > 
-  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" > 
+  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" options:<> > 
   16	        22	norm	ID:17 auth_user_delete:<name:"name1" > 
   17	        23	norm	ID:18 auth_user_get:<name:"name1" > 
   18	        24	norm	ID:19 auth_user_change_password:<name:"name1" password:"pass2" > 
@@ -41,4 +41,4 @@ term	     index	type	data
   27	        33	norm	ID:28 auth_role_revoke_permission:<role:"role3" key:"key" range_end:"rangeend" > 
   27	        34	norm	???
 
-Entry types () count is : 34
+Entry types (Normal,ConfigChange) count is : 34

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listConfigChange.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -11,4 +11,4 @@ term	     index	type	data
    2	         3	conf	method=ConfChangeUpdateNode id=2
    2	         4	conf	method=ConfChangeAddLearnerNode id=3
 
-Entry types (ConfigChange) count is : 4
+Entry types (ConfigChange) count is : 4

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listConfigChangeIRRCompaction.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -12,4 +12,4 @@ term	     index	type	data
    2	         4	conf	method=ConfChangeAddLearnerNode id=3
    8	        14	norm	ID:9 compaction:<physical:true > 
 
-Entry types (ConfigChange,IRRCompaction) count is : 5
+Entry types (ConfigChange,IRRCompaction) count is : 5

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRCompaction.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    8	        14	norm	ID:9 compaction:<physical:true > 
 
-Entry types (IRRCompaction) count is : 1
+Entry types (IRRCompaction) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRDeleteRange.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    6	        12	norm	ID:7 delete_range:<key:"0" range_end:"9" prev_kv:true > 
 
-Entry types (IRRDeleteRange) count is : 1
+Entry types (IRRDeleteRange) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRLeaseGrant.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    9	        15	norm	ID:10 lease_grant:<TTL:1 ID:1 > 
 
-Entry types (IRRLeaseGrant) count is : 1
+Entry types (IRRLeaseGrant) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRLeaseRevoke.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
   10	        16	norm	ID:11 lease_revoke:<ID:2 > 
 
-Entry types (IRRLeaseRevoke) count is : 1
+Entry types (IRRLeaseRevoke) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRPut.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    5	        11	norm	ID:6 put:<key:"foo1" value:"bar1" lease:1 ignore_lease:true > 
 
-Entry types (IRRPut) count is : 1
+Entry types (IRRPut) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRRange.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    4	        10	norm	ID:5 range:<key:"1" range_end:"hi" limit:6 revision:1 sort_order:ASCEND max_mod_revision:20000 max_create_revision:20000 > 
 
-Entry types (IRRRange) count is : 1
+Entry types (IRRRange) count is : 1

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listIRRTxn.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -8,4 +8,4 @@ lastIndex=34
 term	     index	type	data
    7	        13	norm	ID:8 txn:<success:<request_delete_range:<key:"a" range_end:"b" > > failure:<request_delete_range:<key:"a" range_end:"b" > > > 
 
-Entry types (IRRTxn) count is : 1
+Entry types (IRRTxn) count is : 1

+ 3 - 3
tools/etcd-dump-logs/expectedoutput/listInternalRaftRequest.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -17,7 +17,7 @@ term	     index	type	data
   12	        18	norm	ID:13 auth_enable:<> 
   13	        19	norm	ID:14 auth_disable:<> 
   14	        20	norm	ID:15 authenticate:<name:"myname" password:"password" simple_token:"token" > 
-  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" > 
+  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" options:<> > 
   16	        22	norm	ID:17 auth_user_delete:<name:"name1" > 
   17	        23	norm	ID:18 auth_user_get:<name:"name1" > 
   18	        24	norm	ID:19 auth_user_change_password:<name:"name1" password:"pass2" > 
@@ -31,4 +31,4 @@ term	     index	type	data
   26	        32	norm	ID:27 auth_role_grant_permission:<name:"role3" perm:<permType:WRITE key:"Keys" range_end:"RangeEnd" > > 
   27	        33	norm	ID:28 auth_role_revoke_permission:<role:"role3" key:"key" range_end:"rangeend" > 
 
-Entry types (InternalRaftRequest) count is : 24
+Entry types (InternalRaftRequest) count is : 24

+ 3 - 3
tools/etcd-dump-logs/expectedoutput/listNormal.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -22,7 +22,7 @@ term	     index	type	data
   12	        18	norm	ID:13 auth_enable:<> 
   13	        19	norm	ID:14 auth_disable:<> 
   14	        20	norm	ID:15 authenticate:<name:"myname" password:"password" simple_token:"token" > 
-  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" > 
+  15	        21	norm	ID:16 auth_user_add:<name:"name1" password:"pass1" options:<> > 
   16	        22	norm	ID:17 auth_user_delete:<name:"name1" > 
   17	        23	norm	ID:18 auth_user_get:<name:"name1" > 
   18	        24	norm	ID:19 auth_user_change_password:<name:"name1" password:"pass2" > 
@@ -37,4 +37,4 @@ term	     index	type	data
   27	        33	norm	ID:28 auth_role_revoke_permission:<role:"role3" key:"key" range_end:"rangeend" > 
   27	        34	norm	???
 
-Entry types (Normal) count is : 30
+Entry types (Normal) count is : 30

+ 2 - 2
tools/etcd-dump-logs/expectedoutput/listRequest.output

@@ -1,6 +1,6 @@
 Snapshot:
 empty
-Start dupmping log entries from snapshot.
+Start dumping log entries from snapshot.
 WAL metadata:
 nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0
 WAL entries:
@@ -12,4 +12,4 @@ term	     index	type	data
    3	         8	norm	method=DELETE path="/path3"
    3	         9	norm	method=RANDOM path="/path4/superlong/path/path/path/path/path/path/path/path/path/pa"..."path/path/path/path/path/path/path/path/path/path/path/path/path" val="{\"hey\":\"ho\",\"hi\":[\"yo\"]}"
 
-Entry types (Request) count is : 5
+Entry types (Request) count is : 5

+ 12 - 13
tools/etcd-dump-logs/main.go

@@ -38,16 +38,21 @@ import (
 	"go.uber.org/zap"
 )
 
+const (
+	defaultEntryTypes string = "Normal,ConfigChange"
+)
+
 func main() {
 	snapfile := flag.String("start-snap", "", "The base name of snapshot file to start dumping")
 	index := flag.Uint64("start-index", 0, "The index to start dumping")
-	entrytype := flag.String("entry-type", "", `If set, filters output by entry type. Must be one or more than one of:
-	ConfigChange, Normal, Request, InternalRaftRequest,
-	IRRRange, IRRPut, IRRDeleteRange, IRRTxn,
-	IRRCompaction, IRRLeaseGrant, IRRLeaseRevoke, IRRLeaseCheckpoint`)
+	// Default entry types are Normal and ConfigChange
+	entrytype := flag.String("entry-type", defaultEntryTypes, `If set, filters output by entry type. Must be one or more than one of:
+ConfigChange, Normal, Request, InternalRaftRequest,
+IRRRange, IRRPut, IRRDeleteRange, IRRTxn,
+IRRCompaction, IRRLeaseGrant, IRRLeaseRevoke, IRRLeaseCheckpoint`)
 	streamdecoder := flag.String("stream-decoder", "", `The name of an executable decoding tool, the executable must process
-	hex encoded lines of binary input (from etcd-dump-logs)
-	and output a hex encoded line of binary for each input line`)
+hex encoded lines of binary input (from etcd-dump-logs)
+and output a hex encoded line of binary for each input line`)
 
 	flag.Parse()
 
@@ -279,12 +284,6 @@ func evaluateEntrytypeFlag(entrytype string) []EntryFilter {
 		"IRRLeaseCheckpoint":  {passIRRLeaseCheckpoint},
 	}
 	filters := make([]EntryFilter, 0)
-	if len(entrytypelist) == 0 {
-		filters = append(filters, passInternalRaftRequest)
-		filters = append(filters, passRequest)
-		filters = append(filters, passUnknownNormal)
-		filters = append(filters, passConfChange)
-	}
 	for _, et := range entrytypelist {
 		if f, ok := validRequest[et]; ok {
 			filters = append(filters, f...)
@@ -373,7 +372,7 @@ func listEntriesType(entrytype string, streamdecoder string, ents []raftpb.Entry
 		}
 	}
 
-	fmt.Printf("\nEntry types (%s) count is : %d", entrytype, cnt)
+	fmt.Printf("\nEntry types (%s) count is : %d\n", entrytype, cnt)
 }
 
 func parseDecoderOutput(decoderoutput string) (string, string) {