-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ComputeClientV2
methods to manage endpoints
Added `.register_endpoint()`, `.get_endpoint()`, `.get_endpoint_status()` `.get_endpoints()`, `.delete_endpoint()`, and `.lock_endpoint()` methods to the `ComputeClientV2` class.
- Loading branch information
Showing
14 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/globus_sdk/_testing/data/compute/v2/delete_endpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path=f"/v2/endpoints/{ENDPOINT_ID}", | ||
method="DELETE", | ||
json={"result": 302}, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID, SUBSCRIPTION_ID | ||
|
||
ENDPOINT_CONFIG = """ | ||
display_name: My Endpoint | ||
engine: | ||
type: GlobusComputeEngine | ||
""" | ||
|
||
DEFAULT_RESPONSE_DOC = { | ||
"uuid": ENDPOINT_ID, | ||
"name": "my-endpoint", | ||
"display_name": "My Endpoint", | ||
"multi_user": False, | ||
"public": False, | ||
"endpoint_config": ENDPOINT_CONFIG.strip(), | ||
"user_config_template": "", | ||
"user_config_schema": {}, | ||
"description": "My endpoint description", | ||
"hostname": "my-hostname", | ||
"local_user": "user1", | ||
"ip_address": "140.221.112.13", | ||
"endpoint_version": "2.31.0", | ||
"sdk_version": "2.31.0", | ||
"subscription_uuid": SUBSCRIPTION_ID, | ||
} | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path=f"/v2/endpoints/{ENDPOINT_ID}", | ||
method="GET", | ||
json=DEFAULT_RESPONSE_DOC, | ||
), | ||
) |
24 changes: 24 additions & 0 deletions
24
src/globus_sdk/_testing/data/compute/v2/get_endpoint_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID | ||
|
||
DEFAULT_RESPONSE_DOC = { | ||
"status": "online", | ||
"details": { | ||
"total_workers": 1, | ||
"idle_workers": 0, | ||
"pending_tasks": 0, | ||
"outstanding_tasks": 0, | ||
"managers": 1, | ||
}, | ||
} | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path=f"/v2/endpoints/{ENDPOINT_ID}/status", | ||
method="GET", | ||
json=DEFAULT_RESPONSE_DOC, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID, ENDPOINT_ID_2, USER_ID | ||
|
||
DEFAULT_RESPONSE_DOC = [ | ||
{ | ||
"uuid": ENDPOINT_ID, | ||
"name": "my-endpoint", | ||
"display_name": "My Endpoint", | ||
"owner": USER_ID, | ||
}, | ||
{ | ||
"uuid": ENDPOINT_ID_2, | ||
"name": "my-second-endpoint", | ||
"display_name": "My Second Endpoint", | ||
"owner": USER_ID, | ||
}, | ||
] | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID, "endpoint_id_2": ENDPOINT_ID_2}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path="/v2/endpoints", | ||
method="GET", | ||
json=DEFAULT_RESPONSE_DOC, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID | ||
|
||
DEFAULT_RESPONSE_DOC = { | ||
"endpoint_id": ENDPOINT_ID, | ||
"lock_expiration_timestamp": "2021-07-01T00:00:00.000000", | ||
} | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path=f"/v2/endpoints/{ENDPOINT_ID}/lock", | ||
method="POST", | ||
json=DEFAULT_RESPONSE_DOC, | ||
), | ||
) |
29 changes: 29 additions & 0 deletions
29
src/globus_sdk/_testing/data/compute/v2/register_endpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
from .._common import ENDPOINT_ID | ||
|
||
DEFAULT_RESPONSE_DOC = { | ||
"endpoint_id": ENDPOINT_ID, | ||
"task_queue_info": { | ||
"connection_url": "amqps://user:[email protected]", | ||
"exchange": "some_exchange", | ||
"queue": "some_queue", | ||
}, | ||
"result_queue_info": { | ||
"connection_url": "amqps://user:[email protected]", | ||
"exchange": "some_exchange", | ||
"queue": "some_queue", | ||
"queue_publish_kwargs": {}, | ||
}, | ||
"warnings": [], | ||
} | ||
|
||
RESPONSES = ResponseSet( | ||
metadata={"endpoint_id": ENDPOINT_ID}, | ||
default=RegisteredResponse( | ||
service="compute", | ||
path="/v2/endpoints", | ||
method="POST", | ||
json=DEFAULT_RESPONSE_DOC, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
|
||
def test_delete_endpoint(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.delete_endpoint).metadata | ||
res = compute_client_v2.delete_endpoint(endpoint_id=meta["endpoint_id"]) | ||
assert res.http_status == 200 | ||
assert res.data == {"result": 302} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
|
||
def test_get_endpoint(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.get_endpoint).metadata | ||
res = compute_client_v2.get_endpoint(endpoint_id=meta["endpoint_id"]) | ||
assert res.http_status == 200 | ||
assert res.data["uuid"] == meta["endpoint_id"] |
9 changes: 9 additions & 0 deletions
9
tests/functional/services/compute/v2/test_get_endpoint_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
|
||
def test_get_endpoint_status(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.get_endpoint_status).metadata | ||
res = compute_client_v2.get_endpoint_status(endpoint_id=meta["endpoint_id"]) | ||
assert res.http_status == 200 | ||
assert res.data["status"] == "online" |
12 changes: 12 additions & 0 deletions
12
tests/functional/services/compute/v2/test_get_endpoints.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
|
||
def test_get_endpoints(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.get_endpoints).metadata | ||
|
||
res = compute_client_v2.get_endpoints() | ||
|
||
assert res.http_status == 200 | ||
assert res.data[0]["uuid"] == meta["endpoint_id"] | ||
assert res.data[1]["uuid"] == meta["endpoint_id_2"] |
11 changes: 11 additions & 0 deletions
11
tests/functional/services/compute/v2/test_lock_endpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
|
||
def test_lock_endpoint(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.lock_endpoint).metadata | ||
|
||
res = compute_client_v2.lock_endpoint(endpoint_id=meta["endpoint_id"]) | ||
|
||
assert res.http_status == 200 | ||
assert res.data["endpoint_id"] == meta["endpoint_id"] |
39 changes: 39 additions & 0 deletions
39
tests/functional/services/compute/v2/test_register_endpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import uuid | ||
|
||
import globus_sdk | ||
from globus_sdk._testing import load_response | ||
|
||
ENDPOINT_CONFIG = """ | ||
display_name: My Endpoint | ||
engine: | ||
type: GlobusComputeEngine | ||
""" | ||
|
||
|
||
def test_register_endpoint(compute_client_v2: globus_sdk.ComputeClientV2): | ||
meta = load_response(compute_client_v2.register_endpoint).metadata | ||
register_doc = { | ||
"endpoint_uuid": meta["endpoint_id"], | ||
"endpoint_name": "my-endpoint", | ||
"display_name": "My Endpoint", | ||
"version": "2.31.0", | ||
"multi_user": False, | ||
"allowed_functions": [str(uuid.uuid1())], | ||
"authentication_policy": str(uuid.uuid1()), | ||
"metadata": { | ||
"endpoint_config": ENDPOINT_CONFIG.strip(), | ||
"user_config_template": "", | ||
"user_config_schema": {}, | ||
"description": "My endpoint description", | ||
"ip_address": "140.221.112.13", | ||
"hostname": "my-hostname", | ||
"local_user": "user1", | ||
"sdk_version": "2.31.0", | ||
"endpoint_version": "2.31.0", | ||
}, | ||
} | ||
|
||
res = compute_client_v2.register_endpoint(data=register_doc) | ||
|
||
assert res.http_status == 200 | ||
assert res.data["endpoint_id"] == meta["endpoint_id"] |