本文整理汇总了Python中utils.dockerutil.DockerUtil.create_host_config方法的典型用法代码示例。如果您正苦于以下问题:Python DockerUtil.create_host_config方法的具体用法?Python DockerUtil.create_host_config怎么用?Python DockerUtil.create_host_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.dockerutil.DockerUtil
的用法示例。
在下文中一共展示了DockerUtil.create_host_config方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestProxy
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import create_host_config [as 别名]
class TestProxy(AsyncTestCase):
@attr(requires='core_integration')
def test_proxy(self):
config = {
"endpoints": {"https://app.datadoghq.com": ["foo"]},
"proxy_settings": {
"host": "localhost",
"port": PROXY_PORT,
"user": None,
"password": None
}
}
app = Application()
app.skip_ssl_validation = True
app._agentConfig = config
trManager = TransactionManager(MAX_WAIT_FOR_REPLAY, MAX_QUEUE_SIZE, THROTTLING_DELAY)
trManager._flush_without_ioloop = True # Use blocking API to emulate tornado ioloop
CustomAgentTransaction.set_tr_manager(trManager)
app.use_simple_http_client = False # We need proxy capabilities
app.agent_dns_caching = False
# _test is the instance of this class. It is needed to call the method stop() and deal with the asynchronous
# calls as described here : http://www.tornadoweb.org/en/stable/testing.html
CustomAgentTransaction._test = self
CustomAgentTransaction.set_application(app)
CustomAgentTransaction.set_endpoints(config['endpoints'])
CustomAgentTransaction('body', {}, "") # Create and flush the transaction
self.wait()
del CustomAgentTransaction._test
access_log = self.docker_client.exec_start(
self.docker_client.exec_create(CONTAINER_NAME, 'cat /var/log/squid/access.log')['Id'])
self.assertTrue("CONNECT" in access_log) # There should be an entry in the proxy access log
self.assertEquals(len(trManager._endpoints_errors), 1) # There should be an error since we gave a bogus api_key
def setUp(self):
super(TestProxy, self).setUp()
self.docker_client = DockerUtil().client
self.docker_client.pull(CONTAINER_TO_RUN)
self.container = self.docker_client.create_container(CONTAINER_TO_RUN, detach=True, name=CONTAINER_NAME,
ports=[PROXY_PORT], host_config=self.docker_client.create_host_config(port_bindings={3128: PROXY_PORT}))
log.info("Starting container: {0}".format(CONTAINER_TO_RUN))
self.docker_client.start(CONTAINER_NAME)
for line in self.docker_client.logs(CONTAINER_NAME, stdout=True, stream=True):
if "Accepting HTTP Socket connections" in line:
break # Wait for the container to properly start, otherwise we get 'Proxy CONNECT aborted'
def tearDown(self):
log.info("Stopping container: {0}".format(CONTAINER_TO_RUN))
self.docker_client.remove_container(CONTAINER_NAME, force=True)
super(TestProxy, self).tearDown()