mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
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:
parent
9d588319dd
commit
3e9bd931ed
@ -29,13 +29,13 @@ import (
|
||||
"github.com/minio/minio/internal/rest"
|
||||
)
|
||||
|
||||
// ReconnectRPCClient is a wrapper type for rpc.Client which provides reconnect on first failure.
|
||||
type ReconnectRPCClient struct {
|
||||
// ReconnectRESTClient is a wrapper type for rest.Client which provides reconnect on first failure.
|
||||
type ReconnectRESTClient struct {
|
||||
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
|
||||
// connect happens.
|
||||
func newClient(endpoint string) NetLocker {
|
||||
@ -59,24 +59,24 @@ func newClient(endpoint string) NetLocker {
|
||||
DisableCompression: true,
|
||||
}
|
||||
|
||||
return &ReconnectRPCClient{
|
||||
return &ReconnectRESTClient{
|
||||
u: u,
|
||||
rpc: rest.NewClient(u, tr, nil),
|
||||
rest: rest.NewClient(u, tr, nil),
|
||||
}
|
||||
}
|
||||
|
||||
// Close closes the underlying socket file descriptor.
|
||||
func (rpcClient *ReconnectRPCClient) IsOnline() bool {
|
||||
// If rpc client has not connected yet there is nothing to close.
|
||||
return rpcClient.rpc != nil
|
||||
func (restClient *ReconnectRESTClient) IsOnline() bool {
|
||||
// If rest client has not connected yet there is nothing to close.
|
||||
return restClient.rest != nil
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) IsLocal() bool {
|
||||
func (restClient *ReconnectRESTClient) IsLocal() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Close closes the underlying socket file descriptor.
|
||||
func (rpcClient *ReconnectRPCClient) Close() error {
|
||||
func (restClient *ReconnectRESTClient) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ func toLockError(err error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Call makes a RPC call to the remote endpoint using the default codec, namely encoding/gob.
|
||||
func (rpcClient *ReconnectRPCClient) Call(method string, args LockArgs) (status bool, err error) {
|
||||
// Call makes a REST call to the remote endpoint using the msgp codec
|
||||
func (restClient *ReconnectRESTClient) Call(method string, args LockArgs) (status bool, err error) {
|
||||
buf, err := args.MarshalMsg(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
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())
|
||||
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) {
|
||||
return rpcClient.Call("/v1/rlock", args)
|
||||
func (restClient *ReconnectRESTClient) RLock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return restClient.Call("/v1/rlock", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) Lock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return rpcClient.Call("/v1/lock", args)
|
||||
func (restClient *ReconnectRESTClient) Lock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return restClient.Call("/v1/lock", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) RUnlock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return rpcClient.Call("/v1/runlock", args)
|
||||
func (restClient *ReconnectRESTClient) RUnlock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return restClient.Call("/v1/runlock", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) Unlock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return rpcClient.Call("/v1/unlock", args)
|
||||
func (restClient *ReconnectRESTClient) Unlock(ctx context.Context, args LockArgs) (status bool, err error) {
|
||||
return restClient.Call("/v1/unlock", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) Refresh(ctx context.Context, args LockArgs) (refreshed bool, err error) {
|
||||
return rpcClient.Call("/v1/refresh", args)
|
||||
func (restClient *ReconnectRESTClient) Refresh(ctx context.Context, args LockArgs) (refreshed bool, err error) {
|
||||
return restClient.Call("/v1/refresh", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) ForceUnlock(ctx context.Context, args LockArgs) (reply bool, err error) {
|
||||
return rpcClient.Call("/v1/force-unlock", args)
|
||||
func (restClient *ReconnectRESTClient) ForceUnlock(ctx context.Context, args LockArgs) (reply bool, err error) {
|
||||
return restClient.Call("/v1/force-unlock", args)
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) String() string {
|
||||
return rpcClient.u.String()
|
||||
func (restClient *ReconnectRESTClient) String() string {
|
||||
return restClient.u.String()
|
||||
}
|
||||
|
@ -148,13 +148,13 @@ func (lh *lockServerHandler) RLockHandler(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
}
|
||||
|
||||
func stopRPCServers() {
|
||||
func stopLockServers() {
|
||||
for i := 0; i < numberOfNodes; i++ {
|
||||
nodes[i].Close()
|
||||
}
|
||||
}
|
||||
|
||||
func startRPCServers() {
|
||||
func startLockServers() {
|
||||
for i := 0; i < numberOfNodes; i++ {
|
||||
lsrv := &lockServer{
|
||||
mutex: sync.Mutex{},
|
||||
|
@ -30,9 +30,9 @@ import (
|
||||
|
||||
// TestMain initializes the testing framework
|
||||
func TestMain(m *testing.M) {
|
||||
startRPCServers()
|
||||
startLockServers()
|
||||
|
||||
// Initialize net/rpc clients for dsync.
|
||||
// Initialize locker clients for dsync.
|
||||
var clnts []NetLocker
|
||||
for i := 0; i < len(nodes); i++ {
|
||||
clnts = append(clnts, newClient(nodes[i].URL))
|
||||
@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
code := m.Run()
|
||||
stopRPCServers()
|
||||
stopLockServers()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ func TestFailedRefreshLock(t *testing.T) {
|
||||
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] {
|
||||
lockServers[i].setRefreshReply(false)
|
||||
defer lockServers[i].setRefreshReply(true)
|
||||
|
Loading…
Reference in New Issue
Block a user