code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _process_commands(self, content_type, blob):
"""Process all the endpoint configuration and execute things that
user requested.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments of this method.
"""
ctx = self.server.co... | Process all the endpoint configuration and execute things that
user requested.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments of this method.
| _process_commands | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | Apache-2.0 |
def record_requests(self, *_):
"""Enable recording the requests data by the handler."""
with self._context.lock:
self._context.data["record_requests"] = True | Enable recording the requests data by the handler. | record_requests | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | Apache-2.0 |
def get_recorded_requests(self, *_):
"""Fetch all the recorded requests data from the handler"""
with self._context.lock:
requests_list_copy = copy.deepcopy(self._context.data["requests"])
return requests_list_copy | Fetch all the recorded requests data from the handler | get_recorded_requests | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | Apache-2.0 |
def set_encoded_response(self, aux_data):
"""Make endpoint to respond with provided data without encoding data
Arguments:
aux_data (bytes): Encoded bytes array
"""
with self._context.lock:
self._context.data["encoded_response"] = aux_data | Make endpoint to respond with provided data without encoding data
Arguments:
aux_data (bytes): Encoded bytes array
| set_encoded_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | Apache-2.0 |
def _calculate_response(self, base_path, url_args, body_args=None):
"""Reply with the currently set mock-reply for given IAM user query.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
... | Reply with the currently set mock-reply for given IAM user query.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
EndpointException: request URL path is unsupported
| _calculate_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/open/iam.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/open/iam.py | Apache-2.0 |
def _bind_socket(self):
"""Bind to the socket specified by self.SOCKET_PATH
Worth noting is that Nginx setuids to user nobody, thus it is
necessary to give very open permission for the socket so that
it can be accessed by the AR instance
"""
self._socket = socket.socket(... | Bind to the socket specified by self.SOCKET_PATH
Worth noting is that Nginx setuids to user nobody, thus it is
necessary to give very open permission for the socket so that
it can be accessed by the AR instance
| _bind_socket | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def __init__(self, log_catcher):
"""Initialize new SyslogMock instance
Args:
log_catcher (object: LogCatcher()): a LogCatcher instance that is
going to be used by the mock to store captured messages.
"""
self._log_catcher = log_catcher
self._cleanup_... | Initialize new SyslogMock instance
Args:
log_catcher (object: LogCatcher()): a LogCatcher instance that is
going to be used by the mock to store captured messages.
| __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _normalize_line_bytes(line_bytes):
"""Normalize newlines in given bytes array
Args:
line_byes (b''): bytes array that should be normalized
Returns:
Normalized bytes array.
"""
if len(line_bytes) >= 2 and line_bytes.endswith(b'\r\n'):
retu... | Normalize newlines in given bytes array
Args:
line_byes (b''): bytes array that should be normalized
Returns:
Normalized bytes array.
| _normalize_line_bytes | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _read_line_from_fd(self):
"""Read a line from stored file descriptor
Depending on the socket type, either datagram or file interface is
used.
Returns:
A bytes array representing read bytes.
"""
if isinstance(self._fd, socket.socket):
assert s... | Read a line from stored file descriptor
Depending on the socket type, either datagram or file interface is
used.
Returns:
A bytes array representing read bytes.
| _read_line_from_fd | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def __init__(self, fd, log_file, log_level=None):
"""Initialize new LogWriter instance
Args:
fd (obj: python file descriptor): file descriptor from which log
lines should be read.
log_file (str): log all the gathered log lines to file at the
given... | Initialize new LogWriter instance
Args:
fd (obj: python file descriptor): file descriptor from which log
lines should be read.
log_file (str): log all the gathered log lines to file at the
given location
log_level (int): log level with which a... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def drain_all_input(self):
"""Drain all the input from the writer's file descriptor"""
line_bytes = self._read_line_from_fd()
if self._log_fd is not None:
self._append_line_to_log_file(line_bytes)
# yeah, we are guessing encoding here:
line = line_bytes.decode('utf-... | Drain all the input from the writer's file descriptor | drain_all_input | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _register_writer(self, writer):
""" Register new LogWriter object for monitoring
Args:
writer (obj: LogWriter): LogWriter object that should be registered
"""
assert writer.fileno() not in self._writers
self._writers[writer.fileno()] = writer
self._poll.r... | Register new LogWriter object for monitoring
Args:
writer (obj: LogWriter): LogWriter object that should be registered
| _register_writer | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _remove_writer(self, fd_no):
"""Remove LogWriter object from monitoring
Args:
fd_no (int): file descriptor assigned to LogWriter that should be
unregistered
"""
self._poll.unregister(fd_no)
writer = self._writers.pop(fd_no)
writer.stop()
... | Remove LogWriter object from monitoring
Args:
fd_no (int): file descriptor assigned to LogWriter that should be
unregistered
| _remove_writer | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _cleanup_log_dir(self):
"""Remove all the old log file from the log directory
Removes all the old log files from the log directory before logging
anything new. This is necessary because we are always appending to the
logfiles due to multiple instances being created and destroy durin... | Remove all the old log file from the log directory
Removes all the old log files from the log directory before logging
anything new. This is necessary because we are always appending to the
logfiles due to multiple instances being created and destroy during
the tests, and appending to o... | _cleanup_log_dir | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def add_fd(self, fd, log_file, log_level=None):
"""Begin handling new file descriptor
This method adds given file descriptor to the set monitored by
internal poll() call and creates new LogWriter instance for it.
Args:
fd (obj: python file descriptor): file descriptor from ... | Begin handling new file descriptor
This method adds given file descriptor to the set monitored by
internal poll() call and creates new LogWriter instance for it.
Args:
fd (obj: python file descriptor): file descriptor from which log
lines should be read.
... | add_fd | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def stop(self):
"""Stop the LogCatcher instance and perform resource cleanup."""
self._termination_flag.set()
while self._logger_thread.is_alive():
self._logger_thread.join(timeout=0.5)
log.info("Waiting for LogCatcher thread to exit")
log.info("LogCatcher threa... | Stop the LogCatcher instance and perform resource cleanup. | stop | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def __init__(self, log_catcher):
"""Initialize new subprocess instance.
Args:
log_catcher (obj: LogCatcher): a log catcher instance that will
be handling logs/output created by this subprocess.
"""
self._env = {}
self._args = []
self._log_catc... | Initialize new subprocess instance.
Args:
log_catcher (obj: LogCatcher): a log catcher instance that will
be handling logs/output created by this subprocess.
| __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def stdout(self):
"""Return stdout file descriptor of this process"""
assert_msg = "`{}` process must be initialized first".format(self.id)
assert self._process is not None, assert_msg
return self._process.stdout | Return stdout file descriptor of this process | stdout | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def stderr(self):
"""Return stderr file descriptor of this process"""
assert_msg = "`{}` process must be initialized first".format(self.id)
assert self._process is not None, assert_msg
return self._process.stderr | Return stderr file descriptor of this process | stderr | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def start(self):
"""Start a subprocess
This method makes python actually spawn the subprocess and wait for it
to finish initializing.
"""
self._start_subprocess()
self._register_stdout_stderr_to_logcatcher()
if not self._wait_for_subprocess_to_finish_init():
... | Start a subprocess
This method makes python actually spawn the subprocess and wait for it
to finish initializing.
| start | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def stop(self):
"""Stop ManagedSubprocess instance and perform a cleanup
This method makes sure that there are no child processes left after
the object destruction finalizes. In case when a process cannot stop
on it's own, it's forced to using SIGTERM/SIGKILL.
"""
self._... | Stop ManagedSubprocess instance and perform a cleanup
This method makes sure that there are no child processes left after
the object destruction finalizes. In case when a process cannot stop
on it's own, it's forced to using SIGTERM/SIGKILL.
| stop | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _wait_for_subprocess_to_finish_init(self):
"""Monitor process out for indication that the init process is complete
Using internal LogCatcher instance, monitor process output is search of
self._INIT_COMPLETE_STR in one of log lines. If found, it is assumed
that the process has finish... | Monitor process out for indication that the init process is complete
Using internal LogCatcher instance, monitor process output is search of
self._INIT_COMPLETE_STR in one of log lines. If found, it is assumed
that the process has finished init.
| _wait_for_subprocess_to_finish_init | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _set_ar_env_from_val(self, env_name, env_val):
"""Set environment variable for this AR instance
Args:
env_name: name of the environment variable to set
env_val: value that the new environment should have, if None - it
will be skipped/not set.
"""
... | Set environment variable for this AR instance
Args:
env_name: name of the environment variable to set
env_val: value that the new environment should have, if None - it
will be skipped/not set.
| _set_ar_env_from_val | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _set_ar_env_from_environment(self, env_name):
"""Set environment variable for this AR instance basing on existing
environment variable.
This function is esp. useful in cases when certain env. variable
should be copied from existing env vars that pytest runtimes sees.
... | Set environment variable for this AR instance basing on existing
environment variable.
This function is esp. useful in cases when certain env. variable
should be copied from existing env vars that pytest runtimes sees.
Args:
env_name: name of the environment variab... | _set_ar_env_from_environment | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _set_ar_cmdline(self):
"""Helper function used to determine Nginx command line variables
basing on how the instance was configured
"""
openresty_dir = os.environ.get('AR_BIN_DIR')
assert openresty_dir is not None, "'AR_BIN_DIR' env var is not set!"
self.binary = os... | Helper function used to determine Nginx command line variables
basing on how the instance was configured
| _set_ar_cmdline | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _set_ar_env(self,
auth_enabled,
default_scheme,
upstream_mesos,
host_ip,
upstream_marathon,
cache_first_poll_delay,
cache_poll_period,
cache_expiration,
... | Helper function used to determine Nginx env. variables
basing on how the instance was configured
| _set_ar_env | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def make_url_from_path(self, path='/exhibitor/some/path'):
"""A helper function used in tests that is meant to abstract AR
listen port and provide single point of change for updating
the place where all the test expect AR to listen for requests."""
if self._role == 'master':
... | A helper function used in tests that is meant to abstract AR
listen port and provide single point of change for updating
the place where all the test expect AR to listen for requests. | make_url_from_path | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def _register_stdout_stderr_to_logcatcher(self):
"""Please check ManagedSubprocess'es class method description"""
log_filename = 'vegeta.stdout.log'
self._log_catcher.add_fd(self.stdout, log_file=log_filename)
log_filename = 'vegeta.stderr.log'
self._log_catcher.add_fd(self.stde... | Please check ManagedSubprocess'es class method description | _register_stdout_stderr_to_logcatcher | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def __init__(self, log_catcher, target, jwt=None, rate=3):
"""Initialize new Vegeta object
Only GET for now.
Args:
log_catcher (object: LogCatcher()): a LogCatcher instance that is
going to be used by the mock to store captured messages.
"""
super().... | Initialize new Vegeta object
Only GET for now.
Args:
log_catcher (object: LogCatcher()): a LogCatcher instance that is
going to be used by the mock to store captured messages.
| __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/common.py | Apache-2.0 |
def __init__(self,
ouath_client_id="3yF5TOSzdlI45Q1xspxzeoGBe9fNxm9m",
ouath_auth_redirector="https://auth.dcos.io",
auth_token_verification_key_file_path=os.environ.get(
"IAM_PUBKEY_FILE_PATH"),
**base_kwargs):
"""Initiali... | Initialize new AR/Nginx instance
Args:
ouath_client_id (str): translates to `OUATH_CLIENT_ID` env var
ouath_auth_redirector (str): translates to `OUATH_AUTH_REDIRECTOR`
env var
auth_token_verification_key_file_path (str): translates to
`AUT... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/runner/open.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/runner/open.py | Apache-2.0 |
def mocker_s(repo_is_ee, syslog_mock, extra_lo_ips, dns_server_mock_s):
"""Provide a gc-ed mocker instance suitable for the repository flavour"""
if repo_is_ee:
from mocker.ee import Mocker
else:
from mocker.open import Mocker
m = Mocker()
m.start()
yield m
m.stop() | Provide a gc-ed mocker instance suitable for the repository flavour | mocker_s | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def log_catcher():
"""Provide a session-scoped LogCatcher instance for use by other objects"""
lc = LogCatcher()
yield lc
lc.stop() | Provide a session-scoped LogCatcher instance for use by other objects | log_catcher | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def syslog_mock(log_catcher):
"""Provide a session-scoped SyslogMock instance for use by other objects"""
m = SyslogMock(log_catcher)
yield m
m.stop() | Provide a session-scoped SyslogMock instance for use by other objects | syslog_mock | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def dns_server_mock_s(dcos_net_ips, resolvconf_fixup):
"""Set-up DNS mocks, both for agent AR (port 53) and master AR (port 61053)"""
dns_sockets = [
("198.51.100.1", 53),
("198.51.100.2", 53),
("198.51.100.3", 53),
("127.0.0.1", 53),
("127.0.0.1", 61053),
]
s... | Set-up DNS mocks, both for agent AR (port 53) and master AR (port 61053) | dns_server_mock_s | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def dcos_net_ips():
"""Setup IPs that help dns_mock mimic dcos-net"""
ips = ['198.51.100.1', '198.51.100.2', '198.51.100.3']
nflink = pyroute2.IPRoute()
for ip in ips:
add_lo_ipaddr(nflink, ip, 32)
yield
for ip in ips:
del_lo_ipaddr(nflink, ip, 32)
nflink.close() | Setup IPs that help dns_mock mimic dcos-net | dcos_net_ips | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def extra_lo_ips():
"""Setup IPs that are used for simulating e.g. agent, mesos leader, etc.. """
ips = ['127.0.0.2', '127.0.0.3']
nflink = pyroute2.IPRoute()
for ip in ips:
add_lo_ipaddr(nflink, ip, 32)
yield
for ip in ips:
del_lo_ipaddr(nflink, ip, 32)
nflink.close() | Setup IPs that are used for simulating e.g. agent, mesos leader, etc.. | extra_lo_ips | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def nginx_class(repo_is_ee, dns_server_mock_s, log_catcher, syslog_mock, mocker_s):
"""Provide a Nginx class suitable for the repository flavour
This fixture also binds together all the mocks (dns, syslog, mocker(endpoints),
log_catcher), so that tests developer can spawn it's own AR instance if
the de... | Provide a Nginx class suitable for the repository flavour
This fixture also binds together all the mocks (dns, syslog, mocker(endpoints),
log_catcher), so that tests developer can spawn it's own AR instance if
the default ones (master_ar_process/agent_ar_process) are insufficient.
| nginx_class | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def master_ar_process(nginx_class):
"""A go-to AR process instance fixture that should be used in most of the
tests.
We cannot have 'session' scoped AR processes, as some of the tests will
need to start AR with different env vars or AR type (master/agent). So the
idea is to give it 'module' scope a... | A go-to AR process instance fixture that should be used in most of the
tests.
We cannot have 'session' scoped AR processes, as some of the tests will
need to start AR with different env vars or AR type (master/agent). So the
idea is to give it 'module' scope and thus have the same AR instance for
a... | master_ar_process | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def master_ar_process_pertest(nginx_class):
"""An AR process instance fixture for situations where need to trade off
tests speed for having a per-test AR instance
"""
nginx = nginx_class(role="master")
nginx.start()
yield nginx
nginx.stop() | An AR process instance fixture for situations where need to trade off
tests speed for having a per-test AR instance
| master_ar_process_pertest | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def master_ar_process_perclass(nginx_class):
"""An AR process instance fixture for situations where need to trade off
tests speed for having a per-class AR instance
"""
nginx = nginx_class(role="master")
nginx.start()
yield nginx
nginx.stop() | An AR process instance fixture for situations where need to trade off
tests speed for having a per-class AR instance
| master_ar_process_perclass | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def agent_ar_process(nginx_class):
"""
Same as `master_ar_process` fixture except for the fact that it starts 'agent'
nginx instead of `master`.
"""
nginx = nginx_class(role="agent")
nginx.start()
yield nginx
nginx.stop() |
Same as `master_ar_process` fixture except for the fact that it starts 'agent'
nginx instead of `master`.
| agent_ar_process | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def agent_ar_process_pertest(nginx_class):
"""
Same as `master_ar_process_pertest` fixture except for the fact that it
starts 'agent' nginx instead of `master`.
"""
nginx = nginx_class(role="agent")
nginx.start()
yield nginx
nginx.stop() |
Same as `master_ar_process_pertest` fixture except for the fact that it
starts 'agent' nginx instead of `master`.
| agent_ar_process_pertest | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def agent_ar_process_perclass(nginx_class):
"""
Same as `master_ar_process_perclass` fixture except for the fact that it
starts 'agent' nginx instead of `master`.
"""
nginx = nginx_class(role="agent")
nginx.start()
yield nginx
nginx.stop() |
Same as `master_ar_process_perclass` fixture except for the fact that it
starts 'agent' nginx instead of `master`.
| agent_ar_process_perclass | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def jwt_generator(repo_is_ee):
"""Generate valid JWT for given repository flavour and parameters
Both variants support RS256.
This fixture exposes interface where it is possible to manipulate resulting
JWT field values.
"""
key_path = os.getenv('IAM_PRIVKEY_FILE_PATH')
assert key_path is n... | Generate valid JWT for given repository flavour and parameters
Both variants support RS256.
This fixture exposes interface where it is possible to manipulate resulting
JWT field values.
| jwt_generator | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def valid_user_header(jwt_generator):
"""This fixture further simplifies JWT handling by providing a ready-to-use
headers with a valid JSON Web Token for `requests` module to use"""
token = jwt_generator(uid='bozydar')
header = {'Authorization': 'token={}'.format(token)}
return header | This fixture further simplifies JWT handling by providing a ready-to-use
headers with a valid JSON Web Token for `requests` module to use | valid_user_header | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def forged_user_header(jwt_generator):
"""Return JWT token with a forged UID claim"""
token = jwt_generator(uid='bozydar')
# Decode token:
header_bytes, payload_bytes, signature_bytes = [
base64url_decode(_.encode('ascii')) for _ in token.split(".")]
payload_dict = json.loads(payload_bytes.... | Return JWT token with a forged UID claim | forged_user_header | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/conftest.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/conftest.py | Apache-2.0 |
def _assert_filter_regexp_for_invalid_app(
self,
filter_regexp,
app,
nginx_class,
mocker,
auth_headers,
):
"""Helper method that will assert if provided regexp filter is found
in nginx logs for given apps response from M... | Helper method that will assert if provided regexp filter is found
in nginx logs for given apps response from Marathon upstream endpoint.
Arguments:
filter_regexp (dict): Filter definition where key is the message
looked up in logs and value is SearchCriteria definition
... | _assert_filter_regexp_for_invalid_app | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_cache.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_cache.py | Apache-2.0 |
def test_escapes_are_in_upstream_request(
self, master_ar_process_perclass, mocker, valid_user_header
):
"""
Any space, question mark, or hash escaped in a path element of the
`/service` endpoint gets passed through to the service unchanged.
"""
path = urllib.parse.qu... |
Any space, question mark, or hash escaped in a path element of the
`/service` endpoint gets passed through to the service unchanged.
| test_escapes_are_in_upstream_request | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_master.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_master.py | Apache-2.0 |
def test_metrics_html(self, master_ar_process):
"""
/nginx/status returns metrics in HTML format
"""
url = master_ar_process.make_url_from_path('/nginx/status')
resp = requests.get(
url,
allow_redirects=False
)
assert resp.status_code == ... |
/nginx/status returns metrics in HTML format
| test_metrics_html | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | Apache-2.0 |
def test_metrics_prometheus(self, master_ar_process):
"""
/nginx/metrics returns metrics in Prometheus format
"""
url = master_ar_process.make_url_from_path('/nginx/metrics')
resp = requests.get(
url,
allow_redirects=False,
)
assert resp.... |
/nginx/metrics returns metrics in Prometheus format
| test_metrics_prometheus | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | Apache-2.0 |
def test_metrics_prometheus_escape(self, master_ar_process, valid_user_header):
"""
/nginx/metrics escapes Prometheus format correctly.
"""
# https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-format-details
# "label_value can be... |
/nginx/metrics escapes Prometheus format correctly.
| test_metrics_prometheus_escape | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | Apache-2.0 |
def test_metrics_prometheus_histogram(self, master_ar_process, mocker, valid_user_header):
"""
Response times are measured in histogram output.
"""
mocker.send_command(endpoint_id='http://127.0.0.1:8181',
func_name='always_stall',
a... |
Response times are measured in histogram output.
| test_metrics_prometheus_histogram | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_metrics.py | Apache-2.0 |
def test_redirect(self, master_ar_process, valid_user_header, path):
"""
URL's with no slash on end may redirect to the same URL with a
slash appended. If this redirection uses the Host header to write
the redirection, then it is susceptible to a client being tricked
into setting... |
URL's with no slash on end may redirect to the same URL with a
slash appended. If this redirection uses the Host header to write
the redirection, then it is susceptible to a client being tricked
into setting the Host header to a bad host, and then redirecting
the request (includ... | test_redirect | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/test_security.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/test_security.py | Apache-2.0 |
def test_metrics_prometheus_static_upstreams_annotated(
self, master_ar_process, valid_user_header, location, annotation):
"""
/nginx/metrics returns metrics in Prometheus format that are properly
annotated for static upstreams
"""
url = master_ar_process.make_url_fr... |
/nginx/metrics returns metrics in Prometheus format that are properly
annotated for static upstreams
| test_metrics_prometheus_static_upstreams_annotated | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/tests/open/test_metrics.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/tests/open/test_metrics.py | Apache-2.0 |
def _known_exec_directory():
"""
Returns a directory which we have told users to mark as ``exec``.
"""
# This directory must be outside /tmp to support
# environments where /tmp is mounted noexec.
return utils.dcos_lib_path / 'exec' |
Returns a directory which we have told users to mark as ``exec``.
| _known_exec_directory | python | dcos/dcos | packages/bootstrap/extra/dcos_internal_utils/cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/dcos_internal_utils/cli.py | Apache-2.0 |
def _create_private_directory(path, owner):
"""
Create a directory which ``owner`` can create, modify and delete files in
but other non-root users cannot.
Args:
path (pathlib.Path): The path to the directory to create.
owner (str): The owner of the directory.
"""
path.mkdir(pare... |
Create a directory which ``owner`` can create, modify and delete files in
but other non-root users cannot.
Args:
path (pathlib.Path): The path to the directory to create.
owner (str): The owner of the directory.
| _create_private_directory | python | dcos/dcos | packages/bootstrap/extra/dcos_internal_utils/cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/dcos_internal_utils/cli.py | Apache-2.0 |
def _write_file_bytes(filepath, data, mode):
"""
Set the contents of file to a byte string.
The code ensures an atomic write by creating a temporary file and then
moving that temporary file to the given ``filename``. This prevents race
conditions such as the file being read by another process after... |
Set the contents of file to a byte string.
The code ensures an atomic write by creating a temporary file and then
moving that temporary file to the given ``filename``. This prevents race
conditions such as the file being read by another process after it is
created but not yet written to.
It a... | _write_file_bytes | python | dcos/dcos | packages/bootstrap/extra/dcos_internal_utils/utils.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/dcos_internal_utils/utils.py | Apache-2.0 |
def write_file_on_mismatched_content(desired_content, target, write):
"""
Write the contents to a new target.
The copy is atomic, ensuring that the target file never exists with
partial contents. The code avoids writing the file if the contents
do not need to be updated. The return value is a boo... |
Write the contents to a new target.
The copy is atomic, ensuring that the target file never exists with
partial contents. The code avoids writing the file if the contents
do not need to be updated. The return value is a boolean indicating
whether the contents of the file changed.
| write_file_on_mismatched_content | python | dcos/dcos | packages/bootstrap/extra/dcos_internal_utils/utils.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/dcos_internal_utils/utils.py | Apache-2.0 |
def test_telegraf_no_legacy(tmp_path):
"""
When there is no legacy directory `migrate_containers` does not
create a new directory and returns False.
"""
src = tmp_path / 'src'
dst = tmp_path / 'dst'
assert cli.migrate_containers(src, dst) is False
assert not src.exists()
assert not d... |
When there is no legacy directory `migrate_containers` does not
create a new directory and returns False.
| test_telegraf_no_legacy | python | dcos/dcos | packages/bootstrap/extra/tests/test_cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/tests/test_cli.py | Apache-2.0 |
def test_telegraf_migrate_empty(tmp_path):
"""
When the legacy directory exists, `migrate_containers` moves the
directory and returns True.
"""
src = tmp_path / 'src'
dst = tmp_path / 'dst'
src.mkdir()
assert cli.migrate_containers(src, dst) is True
assert not src.exists()
assert... |
When the legacy directory exists, `migrate_containers` moves the
directory and returns True.
| test_telegraf_migrate_empty | python | dcos/dcos | packages/bootstrap/extra/tests/test_cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/tests/test_cli.py | Apache-2.0 |
def test_telegraf_migrate_dst_exists_empty(tmp_path):
"""
Migration works if the target directory exists but is empty.
"""
file_contents = b'1234'
src = tmp_path / 'src'
dst = tmp_path / 'dst'
src.mkdir()
file = src / 'file'
file.write_bytes(file_contents)
dst.mkdir()
assert ... |
Migration works if the target directory exists but is empty.
| test_telegraf_migrate_dst_exists_empty | python | dcos/dcos | packages/bootstrap/extra/tests/test_cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/tests/test_cli.py | Apache-2.0 |
def test_telegraf_migrate_dst_exists_not_empty(tmp_path):
"""
Migration fails if the target directory contains files.
"""
src = tmp_path / 'src'
dst = tmp_path / 'dst'
src.mkdir()
src_file = src / 'src_file'
src_file.touch()
dst.mkdir()
dst_file = dst / 'dst_file'
dst_file.to... |
Migration fails if the target directory contains files.
| test_telegraf_migrate_dst_exists_not_empty | python | dcos/dcos | packages/bootstrap/extra/tests/test_cli.py | https://github.com/dcos/dcos/blob/master/packages/bootstrap/extra/tests/test_cli.py | Apache-2.0 |
def main() -> None:
"""
Add user to database with email argument as the user ID.
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'email',
type=str,
help='E-mail address of the user to be added',
)
args = parser.parse_args()
"""The `args.email` in fact... |
Add user to database with email argument as the user ID.
| main | python | dcos/dcos | packages/bouncer/extra/dcos_add_user.py | https://github.com/dcos/dcos/blob/master/packages/bouncer/extra/dcos_add_user.py | Apache-2.0 |
def migrate_user(uid: str) -> None:
"""
Create a user in IAM service:
https://github.com/dcos/dcos/blob/abaeb5cceedd5661b8d96ff47f8bb5ef212afbdc/packages/dcos-integration-test/extra/test_legacy_user_management.py#L96
"""
url = '{iam}/acs/api/v1/users/{uid}'.format(
iam=IAM_BASE_URL,
... |
Create a user in IAM service:
https://github.com/dcos/dcos/blob/abaeb5cceedd5661b8d96ff47f8bb5ef212afbdc/packages/dcos-integration-test/extra/test_legacy_user_management.py#L96
| migrate_user | python | dcos/dcos | packages/bouncer/extra/iam-migrate-users-from-zk.py | https://github.com/dcos/dcos/blob/master/packages/bouncer/extra/iam-migrate-users-from-zk.py | Apache-2.0 |
def wait_calico_libnetwork_ready():
""" wait until Calico libnetwork plugin and Calico IPAM ready
Calico libnetwork plugin and Calico IPAM are checked according to calico
libnetwork API call:
https://github.com/projectcalico/libnetwork-plugin#monitoring
"""
plugin_address = "/run/docker/plugins... | wait until Calico libnetwork plugin and Calico IPAM ready
Calico libnetwork plugin and Calico IPAM are checked according to calico
libnetwork API call:
https://github.com/projectcalico/libnetwork-plugin#monitoring
| wait_calico_libnetwork_ready | python | dcos/dcos | packages/calico/extra/create-calico-docker-network.py | https://github.com/dcos/dcos/blob/master/packages/calico/extra/create-calico-docker-network.py | Apache-2.0 |
def reload_docker_daemon():
"""
There is no `reload` command on systemctl for Docker. However Docker will
reload the relevant configuration when SIGHUP is sent to its process
"""
docker_pid_file = "/var/run/docker.pid"
if os.path.exists(docker_pid_file):
with open(docker_pid_file, "r") a... |
There is no `reload` command on systemctl for Docker. However Docker will
reload the relevant configuration when SIGHUP is sent to its process
| reload_docker_daemon | python | dcos/dcos | packages/calico/extra/create-calico-docker-network.py | https://github.com/dcos/dcos/blob/master/packages/calico/extra/create-calico-docker-network.py | Apache-2.0 |
def write_file_bytes(filename, data, mode):
"""
Set the contents of file to a byte string.
The code ensures an atomic write by creating a temporary file and then
moving that temporary file to the given ``filename``. This prevents race
conditions such as the file being read by another process after ... |
Set the contents of file to a byte string.
The code ensures an atomic write by creating a temporary file and then
moving that temporary file to the given ``filename``. This prevents race
conditions such as the file being read by another process after it is
created but not yet written to.
It a... | write_file_bytes | python | dcos/dcos | packages/calico/extra/create-calico-docker-network.py | https://github.com/dcos/dcos/blob/master/packages/calico/extra/create-calico-docker-network.py | Apache-2.0 |
def set_num_replicas(my_internal_ip: str, num_replicas: int) -> None:
"""
CockroachDB version 2.1.7 sets the internal system range replication
factor to `5` by default:
https://www.cockroachlabs.com/docs/stable/configure-replication-zones.html#view-all-replication-zones
In order to adjust this to t... |
CockroachDB version 2.1.7 sets the internal system range replication
factor to `5` by default:
https://www.cockroachlabs.com/docs/stable/configure-replication-zones.html#view-all-replication-zones
In order to adjust this to the maximum replication factor possible for a
given DC/OS cluster and to p... | set_num_replicas | python | dcos/dcos | packages/cockroach/extra/cockroachdb-change-config.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/cockroachdb-change-config.py | Apache-2.0 |
def get_expected_master_node_count() -> int:
"""Identify and return the expected number of DC/OS master nodes."""
# This is the expanded DC/OS configuration JSON document w/o sensitive
# values. Read it, parse it.
dcos_cfg_path = '/opt/mesosphere/etc/expanded.config.json'
with open(dcos_cfg_path, '... | Identify and return the expected number of DC/OS master nodes. | get_expected_master_node_count | python | dcos/dcos | packages/cockroach/extra/cockroachdb-change-config.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/cockroachdb-change-config.py | Apache-2.0 |
def dump_database(my_internal_ip: str, out: Union[IO[bytes], IO[str]]) -> None:
"""
Use `cockroach dump` to dump the IAM database to stdout.
It is expected that the operator will redirect the output to
a file or consume it from a backup automation program.
Args:
my_internal_ip: The interna... |
Use `cockroach dump` to dump the IAM database to stdout.
It is expected that the operator will redirect the output to
a file or consume it from a backup automation program.
Args:
my_internal_ip: The internal IP of the current host.
| dump_database | python | dcos/dcos | packages/cockroach/extra/iam-database-backup.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/iam-database-backup.py | Apache-2.0 |
def recover_database(my_internal_ip: str, backup_file_path: str, db_suffix: str) -> None:
"""Recover the IAM database from `backup_file_path`.
1. Use `cockroach sql` to create a temporary database called `iam_new`.
2. Then use `cockroach sql` to load the backup of the IAM database from
`backup_file_... | Recover the IAM database from `backup_file_path`.
1. Use `cockroach sql` to create a temporary database called `iam_new`.
2. Then use `cockroach sql` to load the backup of the IAM database from
`backup_file_path` into the new database.
3. Then rename the active `iam` database to `iam_old`.
4. Fi... | recover_database | python | dcos/dcos | packages/cockroach/extra/iam-database-restore.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/iam-database-restore.py | Apache-2.0 |
def zk_connect(zk_user: Optional[str] = None, zk_secret: Optional[str] = None) -> KazooClient:
"""Connect to ZooKeeper.
On connection failure, the function attempts to reconnect indefinitely with exponential backoff
up to 3 seconds. If a command fails, that command is retried every 300ms for 3 attempts bef... | Connect to ZooKeeper.
On connection failure, the function attempts to reconnect indefinitely with exponential backoff
up to 3 seconds. If a command fails, that command is retried every 300ms for 3 attempts before failing.
These values are chosen to suit a human-interactive time.
Args:
zk_user... | zk_connect | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def _zk_lock(zk: KazooClient, lock_path: str, contender_id: str, timeout: int) -> Generator:
"""
This contextmanager takes a ZooKeeper lock, yields, then releases
the lock. This lock behaves like an interprocess mutex lock.
ZooKeeper allows one to read values without holding a lock, but
there is no... |
This contextmanager takes a ZooKeeper lock, yields, then releases
the lock. This lock behaves like an interprocess mutex lock.
ZooKeeper allows one to read values without holding a lock, but
there is no guarantee that you will read the latest value. To read
the latest value, you must call `sync()`... | _zk_lock | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def _init_cockroachdb_cluster(ip: str) -> None:
"""
Starts CockroachDB listening on `ip`. It waits until the cluster ID is
published via the local gossip endpoint, signalling that the instance has
successfully initialized the cluster. Thereafter it shuts down the
bootstrap CockroachDB instance again... |
Starts CockroachDB listening on `ip`. It waits until the cluster ID is
published via the local gossip endpoint, signalling that the instance has
successfully initialized the cluster. Thereafter it shuts down the
bootstrap CockroachDB instance again.
Args:
ip:
The IP that Cockro... | _init_cockroachdb_cluster | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def _wait_for_cluster_init() -> bool:
"""
CockroachDB Cluster initialization takes a certain amount of time
while the cluster ID and node ID are written to the storage.
If after 5 minutes of attempts the cluster ID is not available raise an
exception.
"""
gossip_... |
CockroachDB Cluster initialization takes a certain amount of time
while the cluster ID and node ID are written to the storage.
If after 5 minutes of attempts the cluster ID is not available raise an
exception.
| _wait_for_cluster_init | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def _get_registered_nodes(zk: KazooClient, zk_path: str) -> List[str]:
"""
Return the IPs of nodes that have registered in ZooKeeper.
The ZNode `zk_path` is expected to exist, having been
created during cluster bootstrap.
Args:
zk:
The client to use to communicate with ZooKeepe... |
Return the IPs of nodes that have registered in ZooKeeper.
The ZNode `zk_path` is expected to exist, having been
created during cluster bootstrap.
Args:
zk:
The client to use to communicate with ZooKeeper.
zk_path:
The path of the ZNode to use for node registra... | _get_registered_nodes | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def _register_cluster_membership(zk: KazooClient, zk_path: str, ip: str) -> List[str]:
"""
Add `ip` to the list of cluster members registered in ZooKeeper.
The ZK lock must be held around the call to this function.
Args:
zk:
The client to use to communicate with ZooKeeper.
... |
Add `ip` to the list of cluster members registered in ZooKeeper.
The ZK lock must be held around the call to this function.
Args:
zk:
The client to use to communicate with ZooKeeper.
zk_path:
The path of the ZNode to use for node registration.
ip:
... | _register_cluster_membership | python | dcos/dcos | packages/cockroach/extra/register.py | https://github.com/dcos/dcos/blob/master/packages/cockroach/extra/register.py | Apache-2.0 |
def dcos_api_session(dcos_api_session_factory: Any) -> Any:
""" Overrides the dcos_api_session fixture to use
exhibitor settings currently used in the cluster
"""
args = dcos_api_session_factory.get_args_from_env()
exhibitor_admin_password = None
expanded_config = get_expanded_config()
if e... | Overrides the dcos_api_session fixture to use
exhibitor settings currently used in the cluster
| dcos_api_session | python | dcos/dcos | packages/dcos-integration-test/extra/conftest.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/conftest.py | Apache-2.0 |
def _purge_marathon_nofail(session: Any) -> None:
"""
Try to clean Marathon.
Do not error if there is a problem.
"""
try:
session.marathon.purge()
except Exception as exc:
log.exception('Ignoring exception during marathon.purge(): %s', exc)
if isinstance(exc, requests.exc... |
Try to clean Marathon.
Do not error if there is a problem.
| _purge_marathon_nofail | python | dcos/dcos | packages/dcos-integration-test/extra/conftest.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/conftest.py | Apache-2.0 |
def clean_marathon_state(dcos_api_session: DcosApiSession) -> Generator:
"""
Attempt to clean up Marathon state before entering the test module and when
leaving the test module. Especially attempt to clean up when the test code
failed. When the cleanup fails do not fail the test but log relevant
inf... |
Attempt to clean up Marathon state before entering the test module and when
leaving the test module. Especially attempt to clean up when the test code
failed. When the cleanup fails do not fail the test but log relevant
information.
| clean_marathon_state | python | dcos/dcos | packages/dcos-integration-test/extra/conftest.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/conftest.py | Apache-2.0 |
def clean_marathon_state_function_scoped(dcos_api_session: DcosApiSession) -> Generator:
"""
See ``clean_marathon_state`` - this is function scoped as some test modules
require cleanup after every test.
"""
_purge_marathon_nofail(session=dcos_api_session)
try:
yield
finally:
... |
See ``clean_marathon_state`` - this is function scoped as some test modules
require cleanup after every test.
| clean_marathon_state_function_scoped | python | dcos/dcos | packages/dcos-integration-test/extra/conftest.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/conftest.py | Apache-2.0 |
def _dump_diagnostics(request: requests.Request, dcos_api_session: DcosApiSession) -> Generator:
"""Download the zipped diagnostics bundle report from each master in the cluster to the home directory. This should
be run last. The _ prefix makes sure that pytest calls this first out of the autouse session scope ... | Download the zipped diagnostics bundle report from each master in the cluster to the home directory. This should
be run last. The _ prefix makes sure that pytest calls this first out of the autouse session scope fixtures, which
means that its post-yield code will be executed last.
* There is no official wa... | _dump_diagnostics | python | dcos/dcos | packages/dcos-integration-test/extra/conftest.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/conftest.py | Apache-2.0 |
def patterns_from_group(group_name: str, test_groups_path: str = 'test_groups.yaml') -> List[str]:
"""
Given a group name, return all the pytest patterns defined for that group
in ``test_groups.yaml``.
"""
test_group_file = Path(test_groups_path)
test_group_file_contents = test_group_file.read_t... |
Given a group name, return all the pytest patterns defined for that group
in ``test_groups.yaml``.
| patterns_from_group | python | dcos/dcos | packages/dcos-integration-test/extra/get_test_group.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/get_test_group.py | Apache-2.0 |
def test_redirect_host(self, dcos_api_session: DcosApiSession, path: str, expected: str) -> None:
"""
Redirection does not propagate a bad Host header
"""
r = dcos_api_session.get(
path,
headers={'Host': 'bad.host'},
allow_redirects=False
)
... |
Redirection does not propagate a bad Host header
| test_redirect_host | python | dcos/dcos | packages/dcos-integration-test/extra/test_adminrouter_open.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_adminrouter_open.py | Apache-2.0 |
def test_accept_gzip(self, dcos_api_session: DcosApiSession) -> None:
"""
Clients that send "Accept-Encoding: gzip" get gzipped responses
for some assets.
"""
r = dcos_api_session.get('/')
r.raise_for_status()
filenames = self.pat.findall(r.text)
assert le... |
Clients that send "Accept-Encoding: gzip" get gzipped responses
for some assets.
| test_accept_gzip | python | dcos/dcos | packages/dcos-integration-test/extra/test_adminrouter_open.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_adminrouter_open.py | Apache-2.0 |
def test_not_accept_gzip(self, dcos_api_session: DcosApiSession) -> None:
"""
Clients that do not send "Accept-Encoding: gzip" do not get gzipped
responses.
"""
r = dcos_api_session.get('/')
r.raise_for_status()
filenames = self.pat.findall(r.text)
assert ... |
Clients that do not send "Accept-Encoding: gzip" do not get gzipped
responses.
| test_not_accept_gzip | python | dcos/dcos | packages/dcos-integration-test/extra/test_adminrouter_open.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_adminrouter_open.py | Apache-2.0 |
def test_invalid_dcos_service_port_index(self, dcos_api_session: DcosApiSession) -> None:
"""
An invalid `DCOS_SERVICE_PORT_INDEX` will not impact the cache refresh.
"""
bad_app = _marathon_container_network_nginx_app(port_index=1)
with dcos_api_session.marathon.deploy_and_cleanu... |
An invalid `DCOS_SERVICE_PORT_INDEX` will not impact the cache refresh.
| test_invalid_dcos_service_port_index | python | dcos/dcos | packages/dcos-integration-test/extra/test_adminrouter_open.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_adminrouter_open.py | Apache-2.0 |
def deploy_test_app_and_check(dcos_api_session: DcosApiSession, app: dict, test_uuid: str) -> None:
"""This method deploys the test server app and then
pings its /operating_environment endpoint to retrieve the container
user running the task.
In a mesos container, this will be the marathon user
In ... | This method deploys the test server app and then
pings its /operating_environment endpoint to retrieve the container
user running the task.
In a mesos container, this will be the marathon user
In a docker container this user comes from the USER setting
from the app's Dockerfile, which, for the test... | deploy_test_app_and_check | python | dcos/dcos | packages/dcos-integration-test/extra/test_applications.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_applications.py | Apache-2.0 |
def test_if_docker_app_can_be_deployed(dcos_api_session: DcosApiSession) -> None:
"""Marathon app inside docker deployment integration test.
Verifies that a marathon app inside of a docker daemon container can be
deployed and accessed as expected.
"""
deploy_test_app_and_check(
dcos_api_ses... | Marathon app inside docker deployment integration test.
Verifies that a marathon app inside of a docker daemon container can be
deployed and accessed as expected.
| test_if_docker_app_can_be_deployed | python | dcos/dcos | packages/dcos-integration-test/extra/test_applications.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_applications.py | Apache-2.0 |
def test_if_ucr_app_can_be_deployed(dcos_api_session: DcosApiSession, healthcheck: Any) -> None:
"""Marathon app inside ucr deployment integration test.
Verifies that a marathon docker app inside of a ucr container can be
deployed and accessed as expected.
"""
deploy_test_app_and_check(
dco... | Marathon app inside ucr deployment integration test.
Verifies that a marathon docker app inside of a ucr container can be
deployed and accessed as expected.
| test_if_ucr_app_can_be_deployed | python | dcos/dcos | packages/dcos-integration-test/extra/test_applications.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_applications.py | Apache-2.0 |
def test_if_marathon_app_can_be_deployed_with_nfs_csi_volume(dcos_api_session: DcosApiSession) -> None:
"""Marathon app deployment integration test using an NFS CSI volume.
This test verifies that a Marathon app can be deployed which attaches to
an NFS volume provided by the NFS CSI plugin. In order to acc... | Marathon app deployment integration test using an NFS CSI volume.
This test verifies that a Marathon app can be deployed which attaches to
an NFS volume provided by the NFS CSI plugin. In order to accomplish this,
we must first set up an NFS share on one agent.
| test_if_marathon_app_can_be_deployed_with_nfs_csi_volume | python | dcos/dcos | packages/dcos-integration-test/extra/test_applications.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_applications.py | Apache-2.0 |
def test_if_marathon_pods_can_be_deployed_with_mesos_containerizer(dcos_api_session: DcosApiSession) -> None:
"""Marathon pods deployment integration test using the Mesos Containerizer
This test verifies that a Marathon pods can be deployed.
"""
test_uuid = uuid.uuid4().hex
# create pod with triv... | Marathon pods deployment integration test using the Mesos Containerizer
This test verifies that a Marathon pods can be deployed.
| test_if_marathon_pods_can_be_deployed_with_mesos_containerizer | python | dcos/dcos | packages/dcos-integration-test/extra/test_applications.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_applications.py | Apache-2.0 |
def test_logout(dcos_api_session: DcosApiSession) -> None:
"""Test logout endpoint. It's a soft logout, instructing
the user agent to delete the authentication cookie, i.e. this test
does not have side effects on other tests.
"""
r = dcos_api_session.get('/acs/api/v1/auth/logout')
cookieheader =... | Test logout endpoint. It's a soft logout, instructing
the user agent to delete the authentication cookie, i.e. this test
does not have side effects on other tests.
| test_logout | python | dcos/dcos | packages/dcos-integration-test/extra/test_auth.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_auth.py | Apache-2.0 |
def test_checks_api(dcos_api_session: DcosApiSession) -> None:
"""
Test the checks API at /system/checks/
This will test that all checks run on all agents return a normal status. A
failure in this test may be an indicator that some unrelated component
failed and dcos-checks functioned properly.
... |
Test the checks API at /system/checks/
This will test that all checks run on all agents return a normal status. A
failure in this test may be an indicator that some unrelated component
failed and dcos-checks functioned properly.
| test_checks_api | python | dcos/dcos | packages/dcos-integration-test/extra/test_checks.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_checks.py | Apache-2.0 |
def test_systemd_units_are_healthy(dcos_api_session: DcosApiSession) -> None:
"""
Test that the system is healthy at the arbitrary point in time
that this test runs. This test has caught several issues in the past
as it serves as a very high-level assertion about the system state.
It seems very rand... |
Test that the system is healthy at the arbitrary point in time
that this test runs. This test has caught several issues in the past
as it serves as a very high-level assertion about the system state.
It seems very random, but it has proven very valuable.
We are explicit about the list of units tha... | test_systemd_units_are_healthy | python | dcos/dcos | packages/dcos-integration-test/extra/test_composition.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_composition.py | Apache-2.0 |
def test_dcos_diagnostics_nodes(dcos_api_session: DcosApiSession) -> None:
"""
test a list of nodes with statuses endpoint /system/health/v1/nodes
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.health.get('/nodes', node=master))
assert len(response) ==... |
test a list of nodes with statuses endpoint /system/health/v1/nodes
| test_dcos_diagnostics_nodes | python | dcos/dcos | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Apache-2.0 |
def test_dcos_diagnostics_nodes_node(dcos_api_session: DcosApiSession) -> None:
"""
test a specific node enpoint /system/health/v1/nodes/<node>
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.health.get('/nodes', node=master))
... |
test a specific node enpoint /system/health/v1/nodes/<node>
| test_dcos_diagnostics_nodes_node | python | dcos/dcos | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Apache-2.0 |
def test_dcos_diagnostics_nodes_node_units(dcos_api_session: DcosApiSession) -> None:
"""
test a list of units from a specific node, endpoint /system/health/v1/nodes/<node>/units
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.heal... |
test a list of units from a specific node, endpoint /system/health/v1/nodes/<node>/units
| test_dcos_diagnostics_nodes_node_units | python | dcos/dcos | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Apache-2.0 |
def test_dcos_diagnostics_nodes_node_units_unit(dcos_api_session: DcosApiSession) -> None:
"""
test a specific unit for a specific node, endpoint /system/health/v1/nodes/<node>/units/<unit>
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.health.get('/nodes', no... |
test a specific unit for a specific node, endpoint /system/health/v1/nodes/<node>/units/<unit>
| test_dcos_diagnostics_nodes_node_units_unit | python | dcos/dcos | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Apache-2.0 |
def test_dcos_diagnostics_units(dcos_api_session: DcosApiSession) -> None:
"""
test a list of collected units, endpoint /system/health/v1/units
"""
# get all unique unit names
all_units = set()
for node in dcos_api_session.masters:
node_response = check_json(dcos_api_session.health.get('... |
test a list of collected units, endpoint /system/health/v1/units
| test_dcos_diagnostics_units | python | dcos/dcos | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.