-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8161 from Param-29/paramm/gateway-k9s
K8s: test-gateway addition to tox
- Loading branch information
Showing
6 changed files
with
169 additions
and
64 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
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 |
---|---|---|
@@ -1,7 +1,23 @@ | ||
# third party | ||
import _pytest | ||
import pytest | ||
|
||
|
||
def pytest_configure(config: _pytest.config.Config) -> None: | ||
config.addinivalue_line("markers", "frontend: frontend integration tests") | ||
config.addinivalue_line("markers", "network: network integration tests") | ||
|
||
|
||
@pytest.fixture | ||
def gateway_port() -> int: | ||
return 9081 | ||
|
||
|
||
@pytest.fixture | ||
def domain_1_port() -> int: | ||
return 9082 | ||
|
||
|
||
@pytest.fixture | ||
def domain_2_port() -> int: | ||
return 9083 |
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,52 @@ | ||
# syft absolute | ||
import syft as sy | ||
from syft.abstract_node import NodeType | ||
from syft.client.domain_client import DomainClient | ||
from syft.client.gateway_client import GatewayClient | ||
from syft.service.network.node_peer import NodePeer | ||
from syft.service.response import SyftSuccess | ||
from syft.service.user.user_roles import ServiceRole | ||
|
||
|
||
def test_domain_connect_to_gateway(domain_1_port, gateway_port): | ||
gateway_client: GatewayClient = sy.login( | ||
port=gateway_port, email="[email protected]", password="changethis" | ||
) | ||
|
||
domain_client: DomainClient = sy.login( | ||
port=domain_1_port, email="[email protected]", password="changethis" | ||
) | ||
|
||
result = domain_client.connect_to_gateway(gateway_client) | ||
assert isinstance(result, SyftSuccess) | ||
|
||
assert len(domain_client.peers) == 1 | ||
assert len(gateway_client.peers) == 1 | ||
|
||
proxy_domain_client = gateway_client.peers[0] | ||
domain_peer = domain_client.peers[0] | ||
|
||
assert isinstance(proxy_domain_client, DomainClient) | ||
assert isinstance(domain_peer, NodePeer) | ||
|
||
# Domain's peer is a gateway and vice-versa | ||
assert domain_peer.node_type == NodeType.GATEWAY | ||
|
||
assert gateway_client.name == domain_peer.name | ||
assert domain_client.name == proxy_domain_client.name | ||
|
||
assert len(gateway_client.domains) == 1 | ||
assert len(gateway_client.enclaves) == 0 | ||
|
||
assert proxy_domain_client.metadata == domain_client.metadata | ||
assert proxy_domain_client.user_role == ServiceRole.NONE | ||
|
||
domain_client.login(email="[email protected]", password="changethis") | ||
proxy_domain_client.login(email="[email protected]", password="changethis") | ||
|
||
assert proxy_domain_client.logged_in_user == "[email protected]" | ||
assert proxy_domain_client.user_role == ServiceRole.ADMIN | ||
assert proxy_domain_client.credentials == domain_client.credentials | ||
assert ( | ||
proxy_domain_client.api.endpoints.keys() == domain_client.api.endpoints.keys() | ||
) |
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