-
Notifications
You must be signed in to change notification settings - Fork 2
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 #62 from wrieg123/authenticated-supervisor
add support for client authentication; fix e2e client tests
- Loading branch information
Showing
4 changed files
with
84 additions
and
33 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,28 +1,37 @@ | ||
import xmlrpc | ||
from time import sleep | ||
|
||
import pytest | ||
|
||
from airflow_supervisor import SupervisorAirflowConfiguration, SupervisorRemoteXMLRPCClient | ||
from airflow_supervisor.client.xmlrpc import ProcessState | ||
|
||
|
||
def test_supervisor_client(supervisor_instance: SupervisorAirflowConfiguration): | ||
client = SupervisorRemoteXMLRPCClient(supervisor_instance) | ||
print(client.getProcessInfo("test")) | ||
sleep(0.5) | ||
print(client.startAllProcesses()) | ||
sleep(0.5) | ||
print(client.getProcessInfo("test")) | ||
sleep(0.5) | ||
print(client.getProcessInfo("test")) | ||
sleep(0.5) | ||
print(client.getProcessInfo("test")) | ||
print(client.startProcess("test")) | ||
sleep(0.5) | ||
print(client.startProcess("test")) | ||
sleep(0.5) | ||
print(client.stopAllProcesses()) | ||
sleep(0.5) | ||
print(client.startProcess("test")) | ||
def _assert_client_actions(client: SupervisorRemoteXMLRPCClient): | ||
assert client.getProcessInfo("test").state == ProcessState.STOPPED | ||
sleep(0.5) | ||
print(client.stopAllProcesses()) | ||
sleep(0.5) | ||
print(client.stopProcess("test")) | ||
assert client.startAllProcesses()["test"].state == ProcessState.RUNNING | ||
sleep(0.5) | ||
assert client.getProcessInfo("test").state == ProcessState.EXITED | ||
assert client.startProcess("test").state == ProcessState.RUNNING | ||
assert client.stopProcess("test").state == ProcessState.STOPPED | ||
assert client.startProcess("test").state == ProcessState.RUNNING | ||
assert client.stopAllProcesses()["test"].state == ProcessState.STOPPED | ||
|
||
|
||
def test_supervisor_client(supervisor_instance: SupervisorAirflowConfiguration): | ||
client = SupervisorRemoteXMLRPCClient(supervisor_instance) | ||
_assert_client_actions(client=client) | ||
|
||
|
||
def test_permissioned_supervisor_client_rejected(permissioned_supervisor_instance: SupervisorAirflowConfiguration): | ||
permissioned_supervisor_instance.airflow.username = "bad-username" | ||
client = SupervisorRemoteXMLRPCClient(permissioned_supervisor_instance) | ||
with pytest.raises(xmlrpc.client.ProtocolError): | ||
client.getProcessInfo("test") | ||
|
||
|
||
def test_permissioned_supervisor_client(permissioned_supervisor_instance: SupervisorAirflowConfiguration): | ||
permissioned_supervisor_instance.airflow.username = "user1" | ||
client = SupervisorRemoteXMLRPCClient(permissioned_supervisor_instance) | ||
_assert_client_actions(client=client) |
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