tests: Remove RPC wording from the code (#14142)

The lock was using net/rpc in the past but it got replaced with a REST API. 
This commit will fix function names/comments to avoid confusion.
This commit is contained in:
Anis Elleuch 2022-01-20 18:36:09 +01:00 committed by GitHub
parent 9d588319dd
commit 3e9bd931ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 36 deletions

View File

@ -29,13 +29,13 @@ import (
"github.com/minio/minio/internal/rest" "github.com/minio/minio/internal/rest"
) )
// ReconnectRPCClient is a wrapper type for rpc.Client which provides reconnect on first failure. // ReconnectRESTClient is a wrapper type for rest.Client which provides reconnect on first failure.
type ReconnectRPCClient struct { type ReconnectRESTClient struct {
u *url.URL u *url.URL
rpc *rest.Client rest *rest.Client
} }
// newClient constructs a ReconnectRPCClient object with addr and endpoint initialized. // newClient constructs a ReconnectRESTClient object with addr and endpoint initialized.
// It _doesn't_ connect to the remote endpoint. See Call method to see when the // It _doesn't_ connect to the remote endpoint. See Call method to see when the
// connect happens. // connect happens.
func newClient(endpoint string) NetLocker { func newClient(endpoint string) NetLocker {
@ -59,24 +59,24 @@ func newClient(endpoint string) NetLocker {
DisableCompression: true, DisableCompression: true,
} }
return &ReconnectRPCClient{ return &ReconnectRESTClient{
u: u, u: u,
rpc: rest.NewClient(u, tr, nil), rest: rest.NewClient(u, tr, nil),
} }
} }
// Close closes the underlying socket file descriptor. // Close closes the underlying socket file descriptor.
func (rpcClient *ReconnectRPCClient) IsOnline() bool { func (restClient *ReconnectRESTClient) IsOnline() bool {
// If rpc client has not connected yet there is nothing to close. // If rest client has not connected yet there is nothing to close.
return rpcClient.rpc != nil return restClient.rest != nil
} }
func (rpcClient *ReconnectRPCClient) IsLocal() bool { func (restClient *ReconnectRESTClient) IsLocal() bool {
return false return false
} }
// Close closes the underlying socket file descriptor. // Close closes the underlying socket file descriptor.
func (rpcClient *ReconnectRPCClient) Close() error { func (restClient *ReconnectRESTClient) Close() error {
return nil return nil
} }
@ -99,14 +99,14 @@ func toLockError(err error) error {
return err return err
} }
// Call makes a RPC call to the remote endpoint using the default codec, namely encoding/gob. // Call makes a REST call to the remote endpoint using the msgp codec
func (rpcClient *ReconnectRPCClient) Call(method string, args LockArgs) (status bool, err error) { func (restClient *ReconnectRESTClient) Call(method string, args LockArgs) (status bool, err error) {
buf, err := args.MarshalMsg(nil) buf, err := args.MarshalMsg(nil)
if err != nil { if err != nil {
return false, err return false, err
} }
body := bytes.NewReader(buf) body := bytes.NewReader(buf)
respBody, err := rpcClient.rpc.Call(context.Background(), method, respBody, err := restClient.rest.Call(context.Background(), method,
url.Values{}, body, body.Size()) url.Values{}, body, body.Size())
defer xhttp.DrainBody(respBody) defer xhttp.DrainBody(respBody)
@ -120,30 +120,30 @@ func (rpcClient *ReconnectRPCClient) Call(method string, args LockArgs) (status
} }
} }
func (rpcClient *ReconnectRPCClient) RLock(ctx context.Context, args LockArgs) (status bool, err error) { func (restClient *ReconnectRESTClient) RLock(ctx context.Context, args LockArgs) (status bool, err error) {
return rpcClient.Call("/v1/rlock", args) return restClient.Call("/v1/rlock", args)
} }
func (rpcClient *ReconnectRPCClient) Lock(ctx context.Context, args LockArgs) (status bool, err error) { func (restClient *ReconnectRESTClient) Lock(ctx context.Context, args LockArgs) (status bool, err error) {
return rpcClient.Call("/v1/lock", args) return restClient.Call("/v1/lock", args)
} }
func (rpcClient *ReconnectRPCClient) RUnlock(ctx context.Context, args LockArgs) (status bool, err error) { func (restClient *ReconnectRESTClient) RUnlock(ctx context.Context, args LockArgs) (status bool, err error) {
return rpcClient.Call("/v1/runlock", args) return restClient.Call("/v1/runlock", args)
} }
func (rpcClient *ReconnectRPCClient) Unlock(ctx context.Context, args LockArgs) (status bool, err error) { func (restClient *ReconnectRESTClient) Unlock(ctx context.Context, args LockArgs) (status bool, err error) {
return rpcClient.Call("/v1/unlock", args) return restClient.Call("/v1/unlock", args)
} }
func (rpcClient *ReconnectRPCClient) Refresh(ctx context.Context, args LockArgs) (refreshed bool, err error) { func (restClient *ReconnectRESTClient) Refresh(ctx context.Context, args LockArgs) (refreshed bool, err error) {
return rpcClient.Call("/v1/refresh", args) return restClient.Call("/v1/refresh", args)
} }
func (rpcClient *ReconnectRPCClient) ForceUnlock(ctx context.Context, args LockArgs) (reply bool, err error) { func (restClient *ReconnectRESTClient) ForceUnlock(ctx context.Context, args LockArgs) (reply bool, err error) {
return rpcClient.Call("/v1/force-unlock", args) return restClient.Call("/v1/force-unlock", args)
} }
func (rpcClient *ReconnectRPCClient) String() string { func (restClient *ReconnectRESTClient) String() string {
return rpcClient.u.String() return restClient.u.String()
} }

View File

@ -148,13 +148,13 @@ func (lh *lockServerHandler) RLockHandler(w http.ResponseWriter, r *http.Request
} }
} }
func stopRPCServers() { func stopLockServers() {
for i := 0; i < numberOfNodes; i++ { for i := 0; i < numberOfNodes; i++ {
nodes[i].Close() nodes[i].Close()
} }
} }
func startRPCServers() { func startLockServers() {
for i := 0; i < numberOfNodes; i++ { for i := 0; i < numberOfNodes; i++ {
lsrv := &lockServer{ lsrv := &lockServer{
mutex: sync.Mutex{}, mutex: sync.Mutex{},

View File

@ -30,9 +30,9 @@ import (
// TestMain initializes the testing framework // TestMain initializes the testing framework
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
startRPCServers() startLockServers()
// Initialize net/rpc clients for dsync. // Initialize locker clients for dsync.
var clnts []NetLocker var clnts []NetLocker
for i := 0; i < len(nodes); i++ { for i := 0; i < len(nodes); i++ {
clnts = append(clnts, newClient(nodes[i].URL)) clnts = append(clnts, newClient(nodes[i].URL))
@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
} }
code := m.Run() code := m.Run()
stopRPCServers() stopLockServers()
os.Exit(code) os.Exit(code)
} }
@ -224,7 +224,7 @@ func TestFailedRefreshLock(t *testing.T) {
t.Skip("skipping test in short mode.") t.Skip("skipping test in short mode.")
} }
// Simulate Refresh RPC response to return no locking found // Simulate Refresh response to return no locking found
for i := range lockServers[:3] { for i := range lockServers[:3] {
lockServers[i].setRefreshReply(false) lockServers[i].setRefreshReply(false)
defer lockServers[i].setRefreshReply(true) defer lockServers[i].setRefreshReply(true)