@@ -19,7 +19,9 @@ import (
19
19
"errors"
20
20
"fmt"
21
21
"io"
22
+ "strconv"
22
23
"strings"
24
+ "time"
23
25
24
26
. "github.com/pingcap/check"
25
27
"github.com/pingcap/failpoint"
@@ -79,6 +81,9 @@ func (s *testOperatorSuite) TestAddRemovePeer(c *C) {
79
81
regionURL := fmt .Sprintf ("%s/operators/%d" , s .urlPrefix , region .GetId ())
80
82
operator := mustReadURL (c , regionURL )
81
83
c .Assert (strings .Contains (operator , "operator not found" ), IsTrue )
84
+ recordURL := fmt .Sprintf ("%s/operators/records?from=%s" , s .urlPrefix , strconv .FormatInt (time .Now ().Unix (), 10 ))
85
+ records := mustReadURL (c , recordURL )
86
+ c .Assert (strings .Contains (records , "operator not found" ), IsTrue )
82
87
83
88
mustPutStore (c , s .svr , 3 , metapb .StoreState_Up , nil )
84
89
err := postJSON (testDialClient , fmt .Sprintf ("%s/operators" , s .urlPrefix ), []byte (`{"name":"add-peer", "region_id": 1, "store_id": 3}` ))
@@ -89,6 +94,8 @@ func (s *testOperatorSuite) TestAddRemovePeer(c *C) {
89
94
90
95
_ , err = doDelete (testDialClient , regionURL )
91
96
c .Assert (err , IsNil )
97
+ records = mustReadURL (c , recordURL )
98
+ c .Assert (strings .Contains (records , "admin-add-peer {add peer: store [3]}" ), IsTrue )
92
99
93
100
err = postJSON (testDialClient , fmt .Sprintf ("%s/operators" , s .urlPrefix ), []byte (`{"name":"remove-peer", "region_id": 1, "store_id": 2}` ))
94
101
c .Assert (err , IsNil )
@@ -98,6 +105,8 @@ func (s *testOperatorSuite) TestAddRemovePeer(c *C) {
98
105
99
106
_ , err = doDelete (testDialClient , regionURL )
100
107
c .Assert (err , IsNil )
108
+ records = mustReadURL (c , recordURL )
109
+ c .Assert (strings .Contains (records , "admin-remove-peer {rm peer: store [2]}" ), IsTrue )
101
110
102
111
mustPutStore (c , s .svr , 4 , metapb .StoreState_Up , nil )
103
112
err = postJSON (testDialClient , fmt .Sprintf ("%s/operators" , s .urlPrefix ), []byte (`{"name":"add-learner", "region_id": 1, "store_id": 4}` ))
@@ -114,6 +123,11 @@ func (s *testOperatorSuite) TestAddRemovePeer(c *C) {
114
123
c .Assert (err , NotNil )
115
124
err = postJSON (testDialClient , fmt .Sprintf ("%s/operators" , s .urlPrefix ), []byte (`{"name":"transfer-region", "region_id": 1, "to_store_ids": [1, 2, 3]}` ))
116
125
c .Assert (err , NotNil )
126
+
127
+ // Fail to get operator if from is latest.
128
+ time .Sleep (time .Second )
129
+ records = mustReadURL (c , fmt .Sprintf ("%s/operators/records?from=%s" , s .urlPrefix , strconv .FormatInt (time .Now ().Unix (), 10 )))
130
+ c .Assert (strings .Contains (records , "operator not found" ), IsTrue )
117
131
}
118
132
119
133
func (s * testOperatorSuite ) TestMergeRegionOperator (c * C ) {
0 commit comments