You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2015/01/28 05:36:39 UTC
[01/50] trafficserver-qa git commit: Merge branch 'master' of
github.com:duderino/tsqa
Repository: trafficserver-qa
Updated Branches:
refs/heads/master [created] 2c0bfaf4c
Merge branch 'master' of github.com:duderino/tsqa
Conflicts:
tsqa/environment.py
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/d848f025
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/d848f025
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/d848f025
Branch: refs/heads/master
Commit: d848f0252f96f5171b4a428fb16e5276e1eecff2
Parents: b1d988f 25e5eee
Author: Joshua Blatt <bl...@yahoo-inc.com>
Authored: Mon Dec 22 16:20:39 2014 -0800
Committer: Joshua Blatt <bl...@yahoo-inc.com>
Committed: Mon Dec 22 16:20:39 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 63 +++++++++++-------------------------------------
tsqa/test_cases.py | 3 ++-
tsqa/utils.py | 15 +++++++++++-
3 files changed, 30 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/d848f025/tsqa/environment.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/d848f025/tsqa/test_cases.py
----------------------------------------------------------------------
[43/50] trafficserver-qa git commit: Clean up open() to be more
pythonic
Posted by jp...@apache.org.
Clean up open() to be more pythonic
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/93628140
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/93628140
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/93628140
Branch: refs/heads/master
Commit: 936281403c38c6c3d502d8e57c684fd9f96c219f
Parents: 9e8a082
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 22 17:10:56 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 22 17:10:56 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/93628140/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 1d6e474..8cf5291 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -351,8 +351,7 @@ class Environment:
os.chmod(os.path.join(self.layout.runtimedir), 0777)
# write out a conveinence script to
- fd = os.open(os.path.join(self.layout.prefix, 'run'), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0755)
- with os.fdopen(fd, 'w') as runscript:
+ with open(os.path.join(self.layout.prefix, 'run'), 'w') as runscript:
runscript.write('#! /usr/bin/env sh\n\n')
runscript.write('# run PROGRAM [ARGS ...]\n')
runscript.write('# Run a Traffic Server program in this environment\n\n')
[45/50] trafficserver-qa git commit: Add some misc fixes
Posted by jp...@apache.org.
Add some misc fixes
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/b7fd08b2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/b7fd08b2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/b7fd08b2
Branch: refs/heads/master
Commit: b7fd08b24b5f5ecce653f94614a4fa0bc2346d2e
Parents: fca6138
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 23 14:38:12 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 23 14:38:12 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 4 ++++
tsqa/utils.py | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/b7fd08b2/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 0faad5e..70300ee 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -5,11 +5,13 @@ import copy
import shutil
import tsqa.utils
import sys
+import time
import tsqa.configs
import tsqa.utils
import logging
+log = logging.getLogger(__name__)
class EnvironmentFactory(object):
'''
@@ -243,12 +245,14 @@ class Environment:
stdout=logfile,
stderr=logfile,
)
+ start = time.time()
# TODO: more specific exception?
try:
tsqa.utils.poll_interfaces(self.hostports)
except:
self.stop() # make sure to stop the daemons
raise
+ log.debug('traffic_cop took {0}s to start up'.format(time.time() - start))
self.cop.poll()
if self.cop.returncode is not None:
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/b7fd08b2/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index a12329a..28f9e45 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -38,7 +38,6 @@ def poll_interfaces(hostports, **kwargs):
try:
s = socket.create_connection((hostname, port),
timeout=connect_timeout_sec,
- source_address=('127.0.0.1', 0), # force the request to come from loopback
)
s.close()
hostports.remove(hostport)
[13/50] trafficserver-qa git commit: Use records config object for
overwriting values, in addition clean up imports
Posted by jp...@apache.org.
Use records config object for overwriting values, in addition clean up imports
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/fcbbd789
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/fcbbd789
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/fcbbd789
Branch: refs/heads/master
Commit: fcbbd789f29189c14a73a867dd5f711c1b52aa99
Parents: 50bd9ff
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 13:54:13 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 13:54:13 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 82 ++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/fcbbd789/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 23970df..ddb7a91 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -6,7 +6,8 @@ import shutil
import json
-from utils import merge_dicts, configure_list, BuildCache, run_sync_command
+import tsqa.configs
+import tsqa.utils
class EnvironmentFactory(object):
@@ -23,7 +24,7 @@ class EnvironmentFactory(object):
default_env=None):
# if no one made the cache class, make it
if self.class_environment_stash is None:
- self.class_environment_stash = BuildCache(env_cache_dir)
+ self.class_environment_stash = tsqa.utils.BuildCache(env_cache_dir)
# TODO: ensure this directory exists? (and is git?)
self.source_dir = source_dir
@@ -45,12 +46,12 @@ class EnvironmentFactory(object):
Autoreconf to make the configure script
'''
# run autoreconf in source tree
- run_sync_command(['autoreconf', '-if'],
- cwd=self.source_dir,
- env=self.default_env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['autoreconf', '-if'],
+ cwd=self.source_dir,
+ env=self.default_env,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
@property
def source_hash(self):
@@ -58,11 +59,11 @@ class EnvironmentFactory(object):
Return the git hash of the source directory
'''
if not hasattr(self , '_source_hash'):
- tmp, _ = run_sync_command(['git', 'rev-parse', 'HEAD'],
- cwd=self.source_dir,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tmp, _ = tsqa.utils.run_sync_command(['git', 'rev-parse', 'HEAD'],
+ cwd=self.source_dir,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
self._source_hash = tmp.strip()
return self._source_hash
@@ -97,11 +98,11 @@ class EnvironmentFactory(object):
if configure is None:
configure = self.default_configure
else:
- configure = merge_dicts(self.default_configure, configure)
+ configure = tsqa.utils.merge_dicts(self.default_configure, configure)
if env is None:
env = self.default_env
else:
- env = merge_dicts(self.default_env, env)
+ env = tsqa.utils.merge_dicts(self.default_env, env)
# blacklist a few things from env, so as to de-dupe builds with diffs of
# only these keys
@@ -122,30 +123,30 @@ class EnvironmentFactory(object):
builddir = tempfile.mkdtemp()
# configure
- args = [os.path.join(self.source_dir, 'configure'), '--prefix=/'] + configure_list(configure)
- run_sync_command(args,
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ args = [os.path.join(self.source_dir, 'configure'), '--prefix=/'] + tsqa.utils.configure_list(configure)
+ tsqa.utils.run_sync_command(args,
+ cwd=builddir,
+ env=env,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
# make
- run_sync_command(['make', '-j'],
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['make', '-j'],
+ cwd=builddir,
+ env=env,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
installdir = tempfile.mkdtemp(dir=self.env_cache_dir)
# make install
- run_sync_command(['make', 'install', 'DESTDIR={0}'.format(installdir)],
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['make', 'install', 'DESTDIR={0}'.format(installdir)],
+ cwd=builddir,
+ env=env,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
shutil.rmtree(builddir) # delete builddir, not useful after install
# stash the env
@@ -284,19 +285,18 @@ class Environment:
if not os.path.exists(dirname):
os.makedirs(dirname)
- self.overrides = {
+ # overwrite a few things that need to be changed to have a unique env
+ records = tsqa.configs.RecordsConfig(os.path.join(self.layout.sysconfdir, 'records.config'))
+ records['CONFIG'].update({
'proxy.config.config_dir': self.layout.sysconfdir,
'proxy.config.body_factory.template_sets_dir': os.path.join(self.layout.sysconfdir, 'body_factory'),
'proxy.config.plugin.plugin_dir': self.layout.plugindir,
'proxy.config.bin_path': self.layout.bindir,
'proxy.config.log.logfile_dir': self.layout.logdir,
'proxy.config.local_state_dir': self.layout.runtimedir,
- }
-
- # Append records.config overrides.
- with open(os.path.join(self.layout.sysconfdir, 'records.config'), 'a+') as records:
- for k, v in self.overrides.iteritems():
- records.write('CONFIG {0} STRING {1}\n'.format(k, v))
+ 'proxy.config.http.server_ports': str(tsqa.utils.bind_unused_port()[1]) # your own listen port
+ })
+ records.write()
def destroy(self):
"""
[40/50] trafficserver-qa git commit: Switch to traffic_cop
Posted by jp...@apache.org.
Switch to traffic_cop
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/358c86b0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/358c86b0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/358c86b0
Branch: refs/heads/master
Commit: 358c86b03fdb9db305d823078dd4751aaadec586
Parents: 498fdda
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 22 14:48:35 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 22 14:48:35 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 48 +++++++++++++++++++++++++++---------------------
tsqa/test_cases.py | 2 +-
2 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/358c86b0/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 0e0173a..f98d3ff 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -46,7 +46,6 @@ class EnvironmentFactory(object):
'''
Autoreconf to make the configure script
'''
-
kwargs = {
'cwd': self.source_dir,
'env': self.default_env,
@@ -116,17 +115,14 @@ class EnvironmentFactory(object):
else:
env = tsqa.utils.merge_dicts(self.default_env, env)
- # blacklist a few things from env, so as to de-dupe builds with diffs of
- # only these keys
- # TODO: only de-dupe for get_key?? for now we don't care since all of these
- # have no effect on build, but if we add one that does we'll care
# TODO: global?
- for blacklisted_key in ('PWD', 'OLDPWD', 'LD_LIBRARY_PATH', 'TS_ROOT', '_'):
- if blacklisted_key in env:
- del env[blacklisted_key]
+ # TODO: other things that can change the build...
+ env_key = {}
+ for whitelisted_key in ('PATH',):
+ env_key[whitelisted_key] = env.get(whitelisted_key)
- key = self._get_key(configure, env)
- self.log.debug('Key is: %s, args are: %s %s' % (key, configure, env))
+ key = self._get_key(configure, env_key)
+ self.log.debug('Key is: %s, args are: %s %s' % (key, configure, env_key))
# if we don't have it built already, lets build it
if key not in self.environment_stash:
@@ -185,7 +181,9 @@ class Layout:
'libdir': 'lib',
'logdir': 'var/log',
'plugindir': 'libexec/trafficserver',
- 'runtimedir': 'var/run',
+ 'runtimedir': 'var/trafficserver',
+ # TODO: change back to var/run after fixing traffic_manager, who doesn't honor proxy.config.local_state_dir
+ #'runtimedir': 'var/run',
'sysconfdir': 'etc/trafficserver',
}
@@ -223,13 +221,8 @@ class Layout:
class Environment:
def __exec_cop(self):
- # TODO: use traffic_cop/manager? Setuid and gid remove LD_LIBRARY_PATH
- # so we can't use them for now
- #path = os.path.join(self.layout.bindir, 'traffic_cop')
- #cmd = [path, '--debug', '--stdout']
-
- path = os.path.join(self.layout.bindir, 'traffic_server')
- cmd = [path]
+ path = os.path.join(self.layout.bindir, 'traffic_cop')
+ cmd = [path, '--debug', '--stdout']
environ = copy.copy(os.environ)
environ['TS_ROOT'] = self.layout.prefix
@@ -245,7 +238,12 @@ class Environment:
stdout=logfile,
stderr=logfile,
)
- tsqa.utils.poll_interfaces(self.hostports)
+ # TODO: more specific exception?
+ try:
+ tsqa.utils.poll_interfaces(self.hostports)
+ except:
+ self.stop() # make sure to stop the daemons
+ raise
self.cop.poll()
if self.cop.returncode is not None:
@@ -309,7 +307,12 @@ class Environment:
http_server_port = tsqa.utils.bind_unused_port()[1]
manager_mgmt_port = tsqa.utils.bind_unused_port()[1]
- self.hostports = [('127.0.0.1', http_server_port), ('127.0.0.1', manager_mgmt_port)]
+ admin_port = tsqa.utils.bind_unused_port()[1]
+
+ self.hostports = [('127.0.0.1', http_server_port),
+ #('127.0.0.1', manager_mgmt_port), # TODO: fix this
+ ('127.0.0.1', admin_port),
+ ]
# overwrite a few things that need to be changed to have a unique env
records = tsqa.configs.RecordsConfig(os.path.join(self.layout.sysconfdir, 'records.config'))
@@ -317,11 +320,14 @@ class Environment:
'proxy.config.config_dir': self.layout.sysconfdir,
'proxy.config.body_factory.template_sets_dir': os.path.join(self.layout.sysconfdir, 'body_factory'),
'proxy.config.plugin.plugin_dir': self.layout.plugindir,
- 'proxy.config.bin_path': self.layout.bindir,
+ 'proxy.config.bin_path': self.layout.bindir, # TODO: symlink over the bins, instead of copying
'proxy.config.log.logfile_dir': self.layout.logdir,
'proxy.config.local_state_dir': self.layout.runtimedir,
'proxy.config.http.server_ports': str(http_server_port), # your own listen port
'proxy.config.process_manager.mgmt_port': manager_mgmt_port, # your own listen port
+ 'proxy.config.admin.autoconf_port': admin_port,
+ 'proxy.config.diags.show_location': 1,
+ 'proxy.config.admin.user_id': '#-1',
})
records.write()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/358c86b0/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index a5e6e2e..35319a8 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -23,7 +23,7 @@ class EnvironmentCase(unittest.TestCase):
def run(self, result=None):
unittest.TestCase.run(self, result)
- self.__successful &= result.wasSuccessful()
+ self.__successful &= result.result.wasSuccessful()
@classmethod
def setUpClass(cls):
[35/50] trafficserver-qa git commit: Add a distclean on each
reconfigure
Posted by jp...@apache.org.
Add a distclean on each reconfigure
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/bf84255a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/bf84255a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/bf84255a
Branch: refs/heads/master
Commit: bf84255a6c2c78cf228a83e3e730be1b4fa2a3df
Parents: 43abdb0
Author: Thomas Jackson <ja...@gmail.com>
Authored: Wed Jan 14 16:31:29 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Wed Jan 14 16:46:57 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/bf84255a/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 3deb224..34e0984 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -59,6 +59,10 @@ class EnvironmentFactory(object):
kwargs['stderr'] = sys.stderr.fileno()
# run autoreconf in source tree
+ try:
+ tsqa.utils.run_sync_command(['make', 'distclean'], **kwargs)
+ except:
+ pass
tsqa.utils.run_sync_command(['autoreconf', '-if'], **kwargs)
@property
[30/50] trafficserver-qa git commit: Don't tear down test env on
object deletion
Posted by jp...@apache.org.
Don't tear down test env on object deletion
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/f4d146db
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/f4d146db
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/f4d146db
Branch: refs/heads/master
Commit: f4d146dbcc20364ba02038fc11c73a62df2ea872
Parents: 9193ee6
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 9 13:02:08 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 9 13:02:08 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/f4d146db/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index c39f388..efe0c1b 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -355,10 +355,6 @@ class Environment:
self.cop.poll()
return self.cop.returncode is not None # its running if it hasn't died
- # TODO: only do this on success, instead of __del__?
- def __del__(self):
- self.destroy()
-
if __name__ == '__main__':
SOURCE_DIR = os.getenv('TSQA_SRC_DIR', '~/trafficserver')
[04/50] trafficserver-qa git commit: Merge branch 'master' of
github.com:jacksontj/tsqa
Posted by jp...@apache.org.
Merge branch 'master' of github.com:jacksontj/tsqa
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9d29420c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9d29420c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9d29420c
Branch: refs/heads/master
Commit: 9d29420c1227c7b765bab4f58b54e2e54d45a4ee
Parents: 53973b3 a765f02
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 17:25:05 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 17:25:05 2014 -0800
----------------------------------------------------------------------
setup.py | 2 +-
tmp/base_envs/env_cache_map.json | 1 -
tsqa/environment.py | 11 ++++++++---
tsqa/test_cases.py | 4 ++--
4 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9d29420c/tsqa/environment.py
----------------------------------------------------------------------
[15/50] trafficserver-qa git commit: Cleanup of cfg_dir and add
"proxies" attribute
Posted by jp...@apache.org.
Cleanup of cfg_dir and add "proxies" attribute
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/82b0fd2d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/82b0fd2d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/82b0fd2d
Branch: refs/heads/master
Commit: 82b0fd2ddd9f3808fee578545b85c16bde11603d
Parents: 03de0c4
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 14:22:15 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 14:22:15 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/82b0fd2d/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 88e6e60..6100c9e 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -28,7 +28,7 @@ class EnvironmentCase(unittest.TestCase):
# create a bunch of config objects that people can access/modify
cls.configs = {
- 'records.config': tsqa.configs.RecordsConfig(os.path.join(cfg_dir, 'records.config'))
+ 'records.config': tsqa.configs.RecordsConfig(os.path.join(cls.environment.layout.sysconfdir, 'records.config'))
}
# call env setup, so people can change configs etc
@@ -67,6 +67,14 @@ class EnvironmentCase(unittest.TestCase):
super(EnvironmentCase, cls).tearDownClass()
cls.environment.destroy() # this will tear down any processes that we started
+ # Some helpful properties
+ @property
+ def proxies(self):
+ '''
+ Return a dict of schema -> proxy. This is primarily used for requests
+ '''
+ # TODO: create a better dict by parsing the config-- to handle http/https ports in the string
+ return {'http': 'http://127.0.0.1:{0}'.format(self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])}
class DynamicHTTPEndpointCase(unittest.TestCase):
'''
[31/50] trafficserver-qa git commit: Make endpoint handle all http
methods
Posted by jp...@apache.org.
Make endpoint handle all http methods
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/733ed1b7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/733ed1b7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/733ed1b7
Branch: refs/heads/master
Commit: 733ed1b7a3c23033530211d63073d9fcffe59599
Parents: f4d146d
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 9 14:53:47 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 9 14:53:47 2015 -0800
----------------------------------------------------------------------
tsqa/endpoint.py | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/733ed1b7/tsqa/endpoint.py
----------------------------------------------------------------------
diff --git a/tsqa/endpoint.py b/tsqa/endpoint.py
index c0a1e31..9f9bc9b 100644
--- a/tsqa/endpoint.py
+++ b/tsqa/endpoint.py
@@ -98,6 +98,11 @@ class DynamicHTTPEndpoint(threading.Thread):
# return a 404 since we didn't find it
return ('', 404)
+ # A little magic to make flask accept *all* methods on the catch_all path
+ for rule in self.app.url_map.iter_rules('hello'):
+ rule.methods = None
+ rule.refresh()
+
def get_tracking_key(self):
'''
Return a new key for tracking a request by key
[06/50] trafficserver-qa git commit: misc fixes
Posted by jp...@apache.org.
misc fixes
- De-dupe some env keys for build cache
- make sure all layout dirs exist on creation/clone
- use traffic_server instead of traffic_cop (for now)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/103e70b3
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/103e70b3
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/103e70b3
Branch: refs/heads/master
Commit: 103e70b3e9344f3d45d812bf366ad0fd35ea6e2e
Parents: 6545cc1
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 18:02:03 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 18:02:03 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/103e70b3/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 7f70d10..2a5a5ea 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -103,7 +103,17 @@ class EnvironmentFactory(object):
else:
env = merge_dicts(self.default_env, env)
+ # blacklist a few things from env, so as to de-dupe builds with diffs of
+ # only these keys
+ # TODO: only de-dupe for get_key?? for now we don't care since all of these
+ # have no effect on build, but if we add one that does we'll care
+ for blacklisted_key in ('PWD', 'OLDPWD'): # TODO: global?
+ if blacklisted_key in env:
+ del env[blacklisted_key]
+
key = self._get_key(configure, env)
+ # TODO: remove
+ print 'Key is:', key, 'args are:', configure, env
# if we don't have it built already, lets build it
if key not in self.environment_stash:
@@ -149,7 +159,6 @@ class EnvironmentFactory(object):
return ret
-# TODO: make this more configurable??
class Layout:
"""
The Layout class is responsible for the set of installation paths within a
@@ -204,9 +213,10 @@ class Layout:
class Environment:
def __exec_cop(self):
- path = os.path.join(self.layout.bindir, 'traffic_cop')
+ path = os.path.join(self.layout.bindir, 'traffic_server') # make traffic_cop
logfile = os.path.join(self.layout.logdir, 'cop.log')
- cmd = [path, '--debug', '--stdout']
+ #cmd = [path, '--debug', '--stdout'] # TODO: re-enable when traffic_cop
+ cmd = [path]
environ = copy.copy(os.environ)
environ['TS_ROOT'] = self.layout.prefix
@@ -246,9 +256,6 @@ class Environment:
else:
os.makedirs(self.layout.prefix)
- for d in ('logdir', 'runtimedir', 'sysconfdir'):
- os.makedirs(getattr(self.layout, d))
-
# Make any other directories we need.
os.makedirs(os.path.join(self.layout.sysconfdir, "body_factory"))
@@ -270,6 +277,12 @@ class Environment:
ignore=None,
)
+ # make sure that all suffixes in new layout exist
+ for name in self.layout.suffixes:
+ dirname = getattr(self.layout, name)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
self.overrides = {
'proxy.config.config_dir': self.layout.sysconfdir,
'proxy.config.body_factory.template_sets_dir': os.path.join(self.layout.sysconfdir, 'body_factory'),
[09/50] trafficserver-qa git commit: Comment addition
Posted by jp...@apache.org.
Comment addition
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/1cec7ac9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/1cec7ac9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/1cec7ac9
Branch: refs/heads/master
Commit: 1cec7ac9f5aaf3170ea52b75569ef638f9a0b307
Parents: 83e515d
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 10:27:19 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 10:27:19 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/1cec7ac9/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index ceff389..419d82c 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -44,7 +44,7 @@ class EnvironmentCase(unittest.TestCase):
def setUpEnv(cls, env):
'''
This funciton is responsible for setting up the environment for this fixture
- This includes everything pre-daemon start
+ This includes everything pre-daemon start (configs, certs, etc.)
'''
pass
[28/50] trafficserver-qa git commit: Don't destroy env on test failure
Posted by jp...@apache.org.
Don't destroy env on test failure
And add some docs and misc cleanup
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/4e51f73a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/4e51f73a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/4e51f73a
Branch: refs/heads/master
Commit: 4e51f73a33dd91591f172d2335364d53c8d86fd3
Parents: 3047c3c
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 8 19:14:18 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 8 19:14:18 2015 -0800
----------------------------------------------------------------------
README.rst | 7 +++++++
tsqa/configs.py | 2 ++
tsqa/environment.py | 2 +-
tsqa/test_cases.py | 21 ++++++++++++++++-----
4 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/4e51f73a/README.rst
----------------------------------------------------------------------
diff --git a/README.rst b/README.rst
index 48b2356..5a6bc55 100644
--- a/README.rst
+++ b/README.rst
@@ -59,3 +59,10 @@ server in a separate thread with APIs to register endpoints and track requests.
test_cases
==========
These are intended to be test cases that you would subclass to create your own test.
+
+
+Environment Variables
+=====================
+TSQA_LAYOUT_PREFIX: Prefix to create layouts for each test execution (defaults to /tmp)
+TSQA_LOG_LEVEL: Log level for TSQA (defaults to INFO)
+TSQA_TMP_DIR: temp directory for building of source (environment factory)
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/4e51f73a/tsqa/configs.py
----------------------------------------------------------------------
diff --git a/tsqa/configs.py b/tsqa/configs.py
index 7a0fbe6..abfec7f 100644
--- a/tsqa/configs.py
+++ b/tsqa/configs.py
@@ -1,3 +1,5 @@
+# TODO: keep track of stat when it was loaded? So we don't clobber manual file changes...
+
class Config(object):
'''
Class to represent a config file
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/4e51f73a/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index fb97bc7..c39f388 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -277,7 +277,7 @@ class Environment:
"""
# First, make the prefix directory.
if self.layout is None:
- self.layout = Layout(tempfile.mkdtemp())
+ self.layout = Layout(tempfile.mkdtemp(prefix=os.environ.get('TSQA_LAYOUT_PREFIX', '')))
else:
os.makedirs(self.layout.prefix)
os.chmod(self.layout.prefix, 0777) # Make the tmp dir readable by all
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/4e51f73a/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index da7f8e9..9708f0c 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -11,15 +11,20 @@ unittest = tsqa.utils.import_unittest()
import os
-# Example environment case
+# Base environment case
class EnvironmentCase(unittest.TestCase):
'''
- This class will get an environment (which is unique) but won't start it
+ This class will get an environment (which is unique)
'''
# TODO: better naming??
environment_factory = {'configure': None,
'env': None,
}
+
+ def run(self, result=None):
+ unittest.TestCase.run(self, result)
+ self.__successful &= result.result.wasSuccessful()
+
@classmethod
def setUpClass(cls):
# call parent constructor
@@ -30,6 +35,7 @@ class EnvironmentCase(unittest.TestCase):
# get an environment
cls.environment = cls.getEnv()
+ logging.info('Environment prefix is {0}'.format(cls.environment.layout.prefix))
cfg_dir = os.path.join(cls.environment.layout.prefix, 'etc', 'trafficserver')
@@ -52,6 +58,9 @@ class EnvironmentCase(unittest.TestCase):
# start ATS
cls.environment.start()
+ # we assume the tests passed
+ cls.__successful = True
+
@classmethod
def getEnv(cls):
'''
@@ -73,15 +82,16 @@ class EnvironmentCase(unittest.TestCase):
@classmethod
def tearDownClass(cls):
- # TODO: some better checking that we didn't crash
- if cls.environment.cop is not None and not cls.environment.running:
+ if not cls.environment.running:
raise Exception('ATS died during the test run')
# stop ATS
cls.environment.stop()
# call parent destructor
super(EnvironmentCase, cls).tearDownClass()
- cls.environment.destroy() # this will tear down any processes that we started
+ # if the test was successful, tear down the env
+ if self.__successful:
+ cls.environment.destroy() # this will tear down any processes that we started
# Some helpful properties
@property
@@ -92,6 +102,7 @@ class EnvironmentCase(unittest.TestCase):
# TODO: create a better dict by parsing the config-- to handle http/https ports in the string
return {'http': 'http://127.0.0.1:{0}'.format(self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])}
+
class DynamicHTTPEndpointCase(unittest.TestCase):
'''
This class will set up a dynamic http endpoint that is local to this class
[37/50] trafficserver-qa git commit: Merge pull request #3 from
bellofreedom/kangli_fix_typo
Posted by jp...@apache.org.
Merge pull request #3 from bellofreedom/kangli_fix_typo
fix typo
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/01f56d5a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/01f56d5a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/01f56d5a
Branch: refs/heads/master
Commit: 01f56d5aab45cc3df91eea7c2276503391b01088
Parents: bf84255 9def2fb
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 15 08:09:13 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 15 08:09:13 2015 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[17/50] trafficserver-qa git commit: Remove layouts on shutdown
Posted by jp...@apache.org.
Remove layouts on shutdown
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/09431178
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/09431178
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/09431178
Branch: refs/heads/master
Commit: 09431178146d618bfb251dee7b0acf9d92f72dff
Parents: b9006c2
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 16:19:27 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 16:20:09 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/09431178/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 29878e7..1cd5fec 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -315,7 +315,7 @@ class Environment:
installed files.
"""
self.stop()
- #shutil.rmtree(self.layout.prefix, ignore_errors=True)
+ shutil.rmtree(self.layout.prefix, ignore_errors=True)
self.layout = Layout(None)
def start(self):
@@ -333,6 +333,7 @@ class Environment:
self.cop.poll()
return self.cop is not None and self.cop.returncode is not None # its running if it hasn't died
+ # TODO: only do this on success, instead of __del__?
def __del__(self):
self.destroy()
[47/50] trafficserver-qa git commit: Allow HTTPEndpoint cases to set
the port #
Posted by jp...@apache.org.
Allow HTTPEndpoint cases to set the port #
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/8987fca2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/8987fca2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/8987fca2
Branch: refs/heads/master
Commit: 8987fca2d748ce534ac279347d43a7f7ed965a12
Parents: 015ef82
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 23 15:26:45 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 23 15:26:45 2015 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/8987fca2/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 35319a8..33f9dc0 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -108,12 +108,13 @@ class DynamicHTTPEndpointCase(unittest.TestCase):
'''
This class will set up a dynamic http endpoint that is local to this class
'''
+ endpoint_port = 0
@classmethod
- def setUpClass(cls, port=0):
+ def setUpClass(cls):
# get a logger
cls.log = logging.getLogger(__name__)
- cls.http_endpoint = tsqa.endpoint.DynamicHTTPEndpoint(port=port)
+ cls.http_endpoint = tsqa.endpoint.DynamicHTTPEndpoint(port=cls.endpoint_port)
cls.http_endpoint.start()
cls.http_endpoint.ready.wait()
[23/50] trafficserver-qa git commit: Cleanup config interfaces
Posted by jp...@apache.org.
Cleanup config interfaces
- Add "add_line" and "add_lines" to config classes
- auto-load all configs in layout.sysconfigdir for all environment cases
- auto-save all configs in environment case after setUpEnv()
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/04c3ab6e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/04c3ab6e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/04c3ab6e
Branch: refs/heads/master
Commit: 04c3ab6ec8b61165b54c7d0a8da67593740f1a1c
Parents: 71fa4c1
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Jan 6 13:30:23 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Jan 6 13:30:23 2015 -0800
----------------------------------------------------------------------
tsqa/configs.py | 30 ++++++++++++++++++++++--------
tsqa/test_cases.py | 14 +++++++++++---
2 files changed, 33 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/04c3ab6e/tsqa/configs.py
----------------------------------------------------------------------
diff --git a/tsqa/configs.py b/tsqa/configs.py
index 2a4cc3e..7a0fbe6 100644
--- a/tsqa/configs.py
+++ b/tsqa/configs.py
@@ -7,6 +7,10 @@ class Config(object):
self.filename = filename
self.load()
+ def add_lines(self, lines):
+ for line in lines:
+ self.add_line(line)
+
def load(self):
with open(self.filename, 'r') as fh:
self.contents = fh.read()
@@ -18,6 +22,10 @@ class Config(object):
with open(self.filename, 'w') as fh:
fh.write(self.contents)
+ def add_line(self, line):
+ if not line.endswith('\n'):
+ line += '\n'
+ self.contents += line
class RecordsConfig(Config, dict):
@@ -47,17 +55,23 @@ class RecordsConfig(Config, dict):
self.load()
+ def _load_line(self, line):
+ line = line.strip()
+ # skip comments
+ if not line or line.startswith('#'):
+ return
+ top_kind, name, kind, val = line.split(' ', 3)
+ if top_kind not in self:
+ self[top_kind] = {}
+ self[top_kind][name] = self.kind_map[kind](val)
+
def load(self):
with open(self.filename, 'r') as fh:
for line in fh:
- line = line.strip()
- # skip comments
- if not line or line.startswith('#'):
- continue
- top_kind, name, kind, val = line.split(' ', 3)
- if top_kind not in self:
- self[top_kind] = {}
- self[top_kind][name] = self.kind_map[kind](val)
+ self._load_line(line)
+
+ def add_line(self, line):
+ self._load_line(line)
def write(self):
with open(self.filename, 'w') as fh:
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/04c3ab6e/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 87885b0..9ee81f9 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -34,13 +34,21 @@ class EnvironmentCase(unittest.TestCase):
cfg_dir = os.path.join(cls.environment.layout.prefix, 'etc', 'trafficserver')
# create a bunch of config objects that people can access/modify
- cls.configs = {
- 'records.config': tsqa.configs.RecordsConfig(os.path.join(cls.environment.layout.sysconfdir, 'records.config'))
- }
+ # classes that override our default config naming
+ config_classes = {'records.config': tsqa.configs.RecordsConfig}
+ # create a mapping of config-name -> config-obj
+ cls.configs = {}
+ for name in os.listdir(cls.environment.layout.sysconfdir):
+ path = os.path.join(cls.environment.layout.sysconfdir, name)
+ if os.path.isfile(path):
+ cls.configs[name] = config_classes.get(name, tsqa.configs.Config)(path)
# call env setup, so people can change configs etc
cls.setUpEnv(cls.environment)
+ for _, cfg in cls.configs.iteritems():
+ cfg.write()
+
# start ATS
cls.environment.start()
[07/50] trafficserver-qa git commit: Cleanup setUpEnv interface (pass
env)
Posted by jp...@apache.org.
Cleanup setUpEnv interface (pass env)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/e0a0c9f0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/e0a0c9f0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/e0a0c9f0
Branch: refs/heads/master
Commit: e0a0c9f08cbfd53fb8e032c604606c61d14395eb
Parents: 103e70b
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 18:21:56 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 18:21:56 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/e0a0c9f0/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 89ad203..ceff389 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -24,7 +24,7 @@ class EnvironmentCase(unittest.TestCase):
cls.environment = cls.getEnv()
# call env setup, so people can change configs etc
- cls.setUpEnv()
+ cls.setUpEnv(cls.environment)
# start ATS
cls.environment.start()
@@ -41,7 +41,7 @@ class EnvironmentCase(unittest.TestCase):
return ef.get_environment()
@classmethod
- def setUpEnv(cls):
+ def setUpEnv(cls, env):
'''
This funciton is responsible for setting up the environment for this fixture
This includes everything pre-daemon start
@@ -64,9 +64,6 @@ class DynamicHTTPEndpointCase(unittest.TestCase):
'''
@classmethod
def setUpClass(cls, port=0):
- # call parent constructor
- super(DynamicHTTPEndpointCase, cls).setUpClass()
-
cls.http_endpoint = tsqa.endpoint.DynamicHTTPEndpoint(port=port)
cls.http_endpoint.start()
@@ -75,10 +72,16 @@ class DynamicHTTPEndpointCase(unittest.TestCase):
# create local requester object
cls.track_requests = tsqa.endpoint.TrackingRequests(cls.http_endpoint)
+ # Do this last, so we can get our stuff registered
+ # call parent constructor
+ super(DynamicHTTPEndpointCase, cls).setUpClass()
+
def endpoint_url(self, path=''):
'''
Get the url for the local dynamic endpoint given a path
'''
+ if path and not path.startswith('/'):
+ path = '/' + path
return 'http://127.0.0.1:{0}{1}'.format(self.http_endpoint.address[1],
path)
[10/50] trafficserver-qa git commit: Add configs for records.config
Posted by jp...@apache.org.
Add configs for records.config
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/f16c79a8
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/f16c79a8
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/f16c79a8
Branch: refs/heads/master
Commit: f16c79a8d3f08b8b59581ace841fe3e1fa0e1eaf
Parents: 1cec7ac
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 10:50:13 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 10:50:13 2014 -0800
----------------------------------------------------------------------
tsqa/configs.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/f16c79a8/tsqa/configs.py
----------------------------------------------------------------------
diff --git a/tsqa/configs.py b/tsqa/configs.py
new file mode 100644
index 0000000..51f563f
--- /dev/null
+++ b/tsqa/configs.py
@@ -0,0 +1,62 @@
+class Config(object):
+ '''
+ Class to represent a config file
+ '''
+
+ def __init__(self, filename):
+ self.filename = filename
+ self.load()
+
+ def load(self):
+ with open(self.filename, 'r') as fh:
+ self.contents = fh.read()
+
+ def write(self):
+ '''
+ Write contents to disk
+ '''
+ with open(self.filename, 'w') as fh:
+ fh.write(self.contents)
+
+
+
+class RecordsConfig(Config, dict):
+ '''
+ Create a "dict" representation of records.config
+ '''
+ kind_map = {'STRING': str,
+ 'INT': int,
+ 'FLOAT': float,
+ }
+
+ reverse_kind_map = {str: 'STRING',
+ int: 'INT',
+ float: 'FLOAT',
+ }
+
+ line_template = 'CONFIG {name} {kind} {val}\n'
+
+ def __init__(self, filename):
+ dict.__init__(self)
+ self.filename = filename
+
+ self.load()
+
+ def load(self):
+ self._config = {}
+ with open(self.filename, 'r') as fh:
+ for line in fh:
+ line = line.strip()
+ # skip comments
+ if line.startswith('#'):
+ continue
+ _, name, kind, val = line.split(' ', 3)
+ self[name] = self.kind_map[kind](val)
+
+ def write(self, dest):
+ with open(dest, 'w') as fh:
+ for name, val in self.iteritems():
+ fh.write(self.line_template.format(name=name,
+ kind=self.reverse_kind_map[type(val)],
+ val=val))
+
[19/50] trafficserver-qa git commit: Add mechanism to set configure
flags from test case
Posted by jp...@apache.org.
Add mechanism to set configure flags from test case
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/32fc37c1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/32fc37c1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/32fc37c1
Branch: refs/heads/master
Commit: 32fc37c16d6b3cf1a3aefa5231803e3d8a868d78
Parents: 8ec6630
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 16:50:43 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 16:50:43 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/32fc37c1/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 72f9633..d7ba75a 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -16,6 +16,10 @@ class EnvironmentCase(unittest.TestCase):
'''
This class will get an environment (which is unique) but won't start it
'''
+ # TODO: better naming??
+ environment_factory = {'configure': None,
+ 'env': None,
+ }
@classmethod
def setUpClass(cls):
# call parent constructor
@@ -48,7 +52,7 @@ class EnvironmentCase(unittest.TestCase):
SOURCE_DIR = os.getenv('TSQA_SRC_DIR', '~/trafficserver')
TMP_DIR = os.getenv('TSQA_TMP_DIR','/tmp/tsqa')
ef = tsqa.environment.EnvironmentFactory(SOURCE_DIR, os.path.join(TMP_DIR, 'base_envs'))
- return ef.get_environment()
+ return ef.get_environment(cls.environment_factory['configure'], cls.environment_factory['env'])
@classmethod
def setUpEnv(cls, env):
[12/50] trafficserver-qa git commit: Add records_config property
(might not keep)
Posted by jp...@apache.org.
Add records_config property (might not keep)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/50bd9ff9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/50bd9ff9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/50bd9ff9
Branch: refs/heads/master
Commit: 50bd9ff907623cc85a95722bd2f1c2aa7cf80622
Parents: ccda9f0
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 13:54:01 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 13:54:01 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/50bd9ff9/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 419d82c..a6a5820 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -4,6 +4,7 @@ Some base test cases that do environment handling for you
import tsqa.endpoint
import tsqa.environment
+import tsqa.configs
import tsqa.utils
unittest = tsqa.utils.import_unittest()
@@ -29,6 +30,15 @@ class EnvironmentCase(unittest.TestCase):
# start ATS
cls.environment.start()
+ cls._config_cache = {}
+
+ @property
+ def records_config(self):
+ if 'records.config' not in self._config_cache:
+ cfg_dir = os.path.join(self.environment.layout.prefix, 'etc', 'trafficserver')
+ self._config_cache['records.config'] = tsqa.configs.RecordsConfig(os.path.join(cfg_dir, 'records.config'))
+ return self._config_cache['records.config']
+
@classmethod
def getEnv(cls):
'''
[29/50] trafficserver-qa git commit: Fix typo
Posted by jp...@apache.org.
Fix typo
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9193ee6b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9193ee6b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9193ee6b
Branch: refs/heads/master
Commit: 9193ee6b12c372ca8cf4a62c4c4aa70a47e3629c
Parents: 4e51f73
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 9 10:14:54 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 9 10:14:54 2015 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9193ee6b/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 9708f0c..3fe70af 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -90,7 +90,7 @@ class EnvironmentCase(unittest.TestCase):
# call parent destructor
super(EnvironmentCase, cls).tearDownClass()
# if the test was successful, tear down the env
- if self.__successful:
+ if cls.__successful:
cls.environment.destroy() # this will tear down any processes that we started
# Some helpful properties
[03/50] trafficserver-qa git commit: Misc cleanup
Posted by jp...@apache.org.
Misc cleanup
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/53973b32
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/53973b32
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/53973b32
Branch: refs/heads/master
Commit: 53973b3227d8b878a4dab6c1881d0284440ce151
Parents: 25e5eee
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 17:24:59 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 17:24:59 2014 -0800
----------------------------------------------------------------------
tsqa/endpoint.py | 6 +++---
tsqa/environment.py | 9 +++++----
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/53973b32/tsqa/endpoint.py
----------------------------------------------------------------------
diff --git a/tsqa/endpoint.py b/tsqa/endpoint.py
index 5d4a145..c0a1e31 100644
--- a/tsqa/endpoint.py
+++ b/tsqa/endpoint.py
@@ -1,12 +1,12 @@
# TODO: some request/response class to load the various libary's implementations and allow for comparison
import os
-
import threading
-from collections import defaultdict
import requests
-
import flask
+
+
+from collections import defaultdict
from wsgiref.simple_server import make_server
# dict of testid -> {client_request, client_response}
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/53973b32/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 0db3d1a..a5d11f5 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -151,11 +151,16 @@ class EnvironmentFactory(object):
# TODO: make this more configurable??
class Layout:
+ """
+ The Layout class is responsible for the set of installation paths within a
+ prefixed Traffic Server instance.
+
# For now, just use a static set of directories relative to TS_ROOT. I
# don't think that this will actually work in the general case, since there
# are still a few paths that are defined by the build that you just have to
# know. Maybe we can deal with that by overriding config in the environment
# when we execute tools.
+ """
suffixes = {
'bindir': 'bin',
'includedir': 'include',
@@ -166,10 +171,6 @@ class Layout:
'sysconfdir': 'etc/trafficserver',
}
- """
- The Layout class is responsible for the set of installation paths within a
- prefixed Traffic Server instance.
- """
def __init__(self, prefix):
self.prefix = prefix
[02/50] trafficserver-qa git commit: Merge pull request #1 from
duderino/master
Posted by jp...@apache.org.
Merge pull request #1 from duderino/master
Generalize to other dev environments
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/a765f028
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/a765f028
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/a765f028
Branch: refs/heads/master
Commit: a765f0287edc804fc28a6f46c9ab8b9d2b5b945f
Parents: 25e5eee d848f02
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 17:23:58 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 17:23:58 2014 -0800
----------------------------------------------------------------------
setup.py | 2 +-
tmp/base_envs/env_cache_map.json | 1 -
tsqa/environment.py | 11 ++++++++---
tsqa/test_cases.py | 4 ++--
4 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
[49/50] trafficserver-qa git commit: More careful about traffic_cop
stopping
Posted by jp...@apache.org.
More careful about traffic_cop stopping
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9bc0c2ff
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9bc0c2ff
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9bc0c2ff
Branch: refs/heads/master
Commit: 9bc0c2ffe6530653008739fd412dd4aae1197aa1
Parents: 6c5e66c
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 23 15:49:44 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 23 15:49:44 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9bc0c2ff/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index e1bf9fa..7af94bb 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -385,11 +385,18 @@ class Environment:
log.debug("Started traffic cop: %s", self.cop)
# TODO: exception if already stopped?
- # TODO: more graceful stop?
def stop(self):
- log.debug("Killing traffic cop: %s", self.cop)
- if self.cop is not None:
+ log.debug("Stopping traffic cop: %s", self.cop)
+ if self.running():
self.cop.kill()
+ # wait for a max of 2s
+ stoptime = time.time() + 2
+ while time.time() < stoptime:
+ # if we got a returncode, we exited
+ if self.cop.poll() is not None:
+ return
+ time.sleep(0.1)
+ log.error('Unable to stop traffic_cop: {0}'.format(self.cop))
self.cop.terminate() # TODO: remove?? or wait...
def running(self):
[44/50] trafficserver-qa git commit: Add nicer defaults to
run_sync_command
Posted by jp...@apache.org.
Add nicer defaults to run_sync_command
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/fca61380
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/fca61380
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/fca61380
Branch: refs/heads/master
Commit: fca61380f2a82874b2686c151b3ad94b49fe99dd
Parents: 9362814
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 22 17:11:08 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 22 17:14:05 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 6 ++++--
tsqa/utils.py | 5 +++++
2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/fca61380/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 8cf5291..0faad5e 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -210,8 +210,10 @@ class Layout:
already have installed.
"""
layout = Layout(None)
- proc = subprocess.Popen(path, shell=False, stderr=open('/dev/null'), stdout=subprocess.PIPE)
- stdout, _ = proc.communicate()
+ stdout, _ = tsqa.utils.run_sync_command(path,
+ shell=False,
+ stdout=subprocess.PIPE,
+ )
for line in stdout.splitlines():
key, val = line.split(': ', 1)
setattr(layout, key.lower(), val)
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/fca61380/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index 0baaca9..a12329a 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -87,6 +87,11 @@ def run_sync_command(*args, **kwargs):
'''
Helper to run a command synchronously
'''
+ if 'stdout' not in kwargs:
+ kwargs['stdout'] = open(os.devnull, 'w')
+ if 'stderr' not in kwargs:
+ kwargs['stderr'] = open(os.devnull, 'w')
+
p = subprocess.Popen(*args, **kwargs)
stdout, stderr = p.communicate()
if p.returncode != 0:
[41/50] trafficserver-qa git commit: Symlink in the binaries from the
bindir.
Posted by jp...@apache.org.
Symlink in the binaries from the bindir.
This will speed up environment cloning and save a lot of disk space. In addition it leaves the test environment with a directory that looks like it should
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/80b147a9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/80b147a9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/80b147a9
Branch: refs/heads/master
Commit: 80b147a92c9ff8a28f559cfaed0af30f40aaa704
Parents: 358c86b
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 22 15:10:17 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 22 15:11:48 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/80b147a9/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index f98d3ff..c2d16cf 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -199,7 +199,7 @@ class Layout:
if self.prefix is None:
return None
# Yay, we have a path.
- return os.path.join(self.prefix, Layout.suffixes[name])
+ return str(os.path.join(self.prefix, Layout.suffixes[name]))
@classmethod
def ParseFromLayout(self, path):
@@ -220,10 +220,8 @@ class Layout:
class Environment:
- def __exec_cop(self):
- path = os.path.join(self.layout.bindir, 'traffic_cop')
- cmd = [path, '--debug', '--stdout']
-
+ @property
+ def shell_env(self):
environ = copy.copy(os.environ)
environ['TS_ROOT'] = self.layout.prefix
@@ -231,10 +229,15 @@ class Environment:
environ['LD_LIBRARY_PATH'] = self.layout.libdir + ':' + environ['LD_LIBRARY_PATH']
else:
environ['LD_LIBRARY_PATH'] = self.layout.libdir
+ return environ
+
+ def __exec_cop(self):
+ path = os.path.join(self.layout.bindir, 'traffic_cop')
+ cmd = [path, '--debug', '--stdout']
with open(os.path.join(self.layout.logdir, 'cop.log'), 'w+') as logfile:
self.cop = subprocess.Popen(cmd,
- env=environ,
+ env=self.shell_env,
stdout=logfile,
stderr=logfile,
)
@@ -288,12 +291,21 @@ class Environment:
for item in os.listdir(layout.prefix):
src_path = os.path.join(layout.prefix, item)
dst_path = os.path.join(self.layout.prefix, item)
- if os.path.isdir(src_path):
+ # if its the bindir, lets symlink in everything
+ if item == layout.suffixes['bindir']:
+ os.makedirs(dst_path) # make the dest dir
+ for bin_item in os.listdir(src_path):
+ os.symlink(os.path.join(src_path, bin_item),
+ os.path.join(dst_path, bin_item),
+ )
+
+ elif os.path.isdir(src_path):
shutil.copytree(src_path,
dst_path,
symlinks=True,
ignore=None,
)
+
elif os.path.isfile(src_path):
shutil.copyfile(src_path, dst_path)
@@ -320,7 +332,7 @@ class Environment:
'proxy.config.config_dir': self.layout.sysconfdir,
'proxy.config.body_factory.template_sets_dir': os.path.join(self.layout.sysconfdir, 'body_factory'),
'proxy.config.plugin.plugin_dir': self.layout.plugindir,
- 'proxy.config.bin_path': self.layout.bindir, # TODO: symlink over the bins, instead of copying
+ 'proxy.config.bin_path': self.layout.bindir,
'proxy.config.log.logfile_dir': self.layout.logdir,
'proxy.config.local_state_dir': self.layout.runtimedir,
'proxy.config.http.server_ports': str(http_server_port), # your own listen port
@@ -334,6 +346,17 @@ class Environment:
os.chmod(os.path.join(os.path.dirname(self.layout.runtimedir)), 0777)
os.chmod(os.path.join(self.layout.runtimedir), 0777)
+ # write out a conveinence script to
+ fd = os.open(os.path.join(self.layout.prefix, 'run'), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0755)
+ with os.fdopen(fd, 'w') as runscript:
+ runscript.write('#! /usr/bin/env sh\n\n')
+ runscript.write('# run PROGRAM [ARGS ...]\n')
+ runscript.write('# Run a Traffic Server program in this environment\n\n')
+ for k, v in self.shell_env.iteritems():
+ runscript.write('{0}="{1}"\n'.format(k, v))
+ runscript.write('export {0}\n\n'.format(k))
+ runscript.write('exec "$@"\n')
+
def destroy(self):
"""
Tear down the environment. Kill any running processes and remove any
[16/50] trafficserver-qa git commit: More fixes for making base tsqa
tests work
Posted by jp...@apache.org.
More fixes for making base tsqa tests work
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/b9006c23
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/b9006c23
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/b9006c23
Branch: refs/heads/master
Commit: b9006c23725d087aa31dbc48dee1d8007b7bb67d
Parents: 82b0fd2
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 16:04:52 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 16:04:52 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 36 ++++++++++++++++++++++++------------
tsqa/test_cases.py | 3 +++
2 files changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/b9006c23/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index ddb7a91..29878e7 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -215,30 +215,34 @@ class Layout:
class Environment:
def __exec_cop(self):
- path = os.path.join(self.layout.bindir, 'traffic_server') # make traffic_cop
- logfile = os.path.join(self.layout.logdir, 'cop.log')
- #cmd = [path, '--debug', '--stdout'] # TODO: re-enable when traffic_cop
+ # TODO: use traffic_cop/manager? Setuid and gid remove LD_LIBRARY_PATH
+ # so we can't use them for now
+ #path = os.path.join(self.layout.bindir, 'traffic_cop')
+ #cmd = [path, '--debug', '--stdout']
+
+ path = os.path.join(self.layout.bindir, 'traffic_server')
cmd = [path]
environ = copy.copy(os.environ)
environ['TS_ROOT'] = self.layout.prefix
- if environ.has_key('LD_LIBRARY_PATH'):
+ if environ.has_key('LD_LIBRARY_PATH') and self.layout.libdir not in environ['LD_LIBRARY_PATH'].split(':'):
environ['LD_LIBRARY_PATH'] = self.layout.libdir + ':' + environ['LD_LIBRARY_PATH']
else:
environ['LD_LIBRARY_PATH'] = self.layout.libdir
- # XXX We ought to be pointing traffic_cop to its records.config using
- # proxy.config.config_dir in the environment, but traffic_cop doesn't
- # look at that (yet).
with open(os.path.join(self.layout.logdir, 'cop.log'), 'w+') as logfile:
self.cop = subprocess.Popen(cmd,
env=environ,
- #stdout=logfile,
- #stderr=logfile,
+ stdout=logfile,
+ stderr=logfile,
)
import time
time.sleep(3) # TODO: wait or the process to listen?
+ # TODO: better checking...
+ self.cop.poll()
+ if self.cop.returncode is not None:
+ raise Exception(self.cop.returncode)
def __init__(self, layout=None):
"""
@@ -270,6 +274,7 @@ class Environment:
self.layout = Layout(tempfile.mkdtemp())
else:
os.makedirs(self.layout.prefix)
+ os.chmod(self.layout.prefix, 0777) # Make the tmp dir readable by all
# copy all files from old layout to new one
for item in os.listdir(layout.prefix):
@@ -283,7 +288,9 @@ class Environment:
for name in self.layout.suffixes:
dirname = getattr(self.layout, name)
if not os.path.exists(dirname):
- os.makedirs(dirname)
+ os.makedirs(dirname, 0777)
+ else:
+ os.chmod(dirname, 0777)
# overwrite a few things that need to be changed to have a unique env
records = tsqa.configs.RecordsConfig(os.path.join(self.layout.sysconfdir, 'records.config'))
@@ -294,17 +301,21 @@ class Environment:
'proxy.config.bin_path': self.layout.bindir,
'proxy.config.log.logfile_dir': self.layout.logdir,
'proxy.config.local_state_dir': self.layout.runtimedir,
- 'proxy.config.http.server_ports': str(tsqa.utils.bind_unused_port()[1]) # your own listen port
+ 'proxy.config.http.server_ports': str(tsqa.utils.bind_unused_port()[1]), # your own listen port
+ 'proxy.config.process_manager.mgmt_port': tsqa.utils.bind_unused_port()[1], # your own listen port
})
records.write()
+ os.chmod(os.path.join(os.path.dirname(self.layout.runtimedir)), 0777)
+ os.chmod(os.path.join(self.layout.runtimedir), 0777)
+
def destroy(self):
"""
Tear down the environment. Kill any running processes and remove any
installed files.
"""
self.stop()
- shutil.rmtree(self.layout.prefix, ignore_errors=True)
+ #shutil.rmtree(self.layout.prefix, ignore_errors=True)
self.layout = Layout(None)
def start(self):
@@ -319,6 +330,7 @@ class Environment:
self.cop.terminate() # TODO: remove?? or wait...
def running(self):
+ self.cop.poll()
return self.cop is not None and self.cop.returncode is not None # its running if it hasn't died
def __del__(self):
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/b9006c23/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 6100c9e..72f9633 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -60,6 +60,9 @@ class EnvironmentCase(unittest.TestCase):
@classmethod
def tearDownClass(cls):
+ # TODO: some better checking that we didn't crash
+ if cls.environment.cop is not None and not cls.environment.running:
+ raise Exception('ATS died during the test run')
# stop ATS
cls.environment.stop()
[42/50] trafficserver-qa git commit: Fix timeout problems with
traffic_manager
Posted by jp...@apache.org.
Fix timeout problems with traffic_manager
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9e8a082a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9e8a082a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9e8a082a
Branch: refs/heads/master
Commit: 9e8a082ad1ddecfaf535f17e821256924467c9ee
Parents: 80b147a
Author: Thomas Jackson <ja...@gmail.com>
Authored: Thu Jan 22 17:07:05 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Thu Jan 22 17:07:05 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 6 +++++-
tsqa/utils.py | 8 +++++---
2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9e8a082a/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index c2d16cf..1d6e474 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -322,7 +322,7 @@ class Environment:
admin_port = tsqa.utils.bind_unused_port()[1]
self.hostports = [('127.0.0.1', http_server_port),
- #('127.0.0.1', manager_mgmt_port), # TODO: fix this
+ ('127.0.0.1', manager_mgmt_port),
('127.0.0.1', admin_port),
]
@@ -340,6 +340,10 @@ class Environment:
'proxy.config.admin.autoconf_port': admin_port,
'proxy.config.diags.show_location': 1,
'proxy.config.admin.user_id': '#-1',
+
+ # set the process_server timeouts to 0 (faster startup)
+ 'proxy.config.lm.pserver_timeout_secs': 0,
+ 'proxy.config.lm.pserver_timeout_msecs': 0,
})
records.write()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9e8a082a/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index 4f63a2a..0baaca9 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -18,7 +18,7 @@ def poll_interfaces(hostports, **kwargs):
'''
connect_timeout_sec = 1
- poll_sleep_sec = 1
+ poll_sleep_sec = 0.1
if kwargs.has_key('timeout_sec'):
timeout = time.time() + kwargs['timeout_sec']
@@ -35,9 +35,11 @@ def poll_interfaces(hostports, **kwargs):
log.debug("Checking interface '%s:%d'", hostname, port)
# This supports IPv6
-
try:
- s = socket.create_connection((hostname, port), timeout=connect_timeout_sec)
+ s = socket.create_connection((hostname, port),
+ timeout=connect_timeout_sec,
+ source_address=('127.0.0.1', 0), # force the request to come from loopback
+ )
s.close()
hostports.remove(hostport)
[08/50] trafficserver-qa git commit: Add LD_LIBRARY_PATH and TS_ROOT
to env blacklistedkey
Posted by jp...@apache.org.
Add LD_LIBRARY_PATH and TS_ROOT to env blacklistedkey
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/83e515d8
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/83e515d8
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/83e515d8
Branch: refs/heads/master
Commit: 83e515d81269ce76784e098a1335d32357aa3253
Parents: e0a0c9f
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 18:22:29 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 18:22:29 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/83e515d8/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 2a5a5ea..314fdab 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -107,7 +107,8 @@ class EnvironmentFactory(object):
# only these keys
# TODO: only de-dupe for get_key?? for now we don't care since all of these
# have no effect on build, but if we add one that does we'll care
- for blacklisted_key in ('PWD', 'OLDPWD'): # TODO: global?
+ # TODO: global?
+ for blacklisted_key in ('PWD', 'OLDPWD', 'LD_LIBRARY_PATH', 'TS_ROOT'):
if blacklisted_key in env:
del env[blacklisted_key]
[18/50] trafficserver-qa git commit: Fix plugin dir (to be the
correct one)
Posted by jp...@apache.org.
Fix plugin dir (to be the correct one)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/8ec66303
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/8ec66303
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/8ec66303
Branch: refs/heads/master
Commit: 8ec663035c0fd413e86a92ad9715cc204e9f89d0
Parents: 0943117
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 16:33:22 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 16:33:22 2014 -0800
----------------------------------------------------------------------
tsqa/environment.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/8ec66303/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 1cd5fec..cd5b747 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -177,7 +177,7 @@ class Layout:
'includedir': 'include',
'libdir': 'lib',
'logdir': 'var/log',
- 'plugindir': 'lib/plugins',
+ 'plugindir': 'libexec/trafficserver',
'runtimedir': 'var/run',
'sysconfdir': 'etc/trafficserver',
}
@@ -242,7 +242,7 @@ class Environment:
# TODO: better checking...
self.cop.poll()
if self.cop.returncode is not None:
- raise Exception(self.cop.returncode)
+ raise Exception(self.cop.returncode, self.layout.prefix)
def __init__(self, layout=None):
"""
[50/50] trafficserver-qa git commit: Cleanup readme
Posted by jp...@apache.org.
Cleanup readme
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/2c0bfaf4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/2c0bfaf4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/2c0bfaf4
Branch: refs/heads/master
Commit: 2c0bfaf4cca2b0ee5a2dab73366f0d1fa933e944
Parents: 9bc0c2f
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Jan 26 15:11:45 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Jan 26 15:12:51 2015 -0800
----------------------------------------------------------------------
README.rst | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/2c0bfaf4/README.rst
----------------------------------------------------------------------
diff --git a/README.rst b/README.rst
index 5a6bc55..5678c03 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,3 @@
-# TODO: rename from tsqa?
=============
What is TSQA?
=============
@@ -66,3 +65,9 @@ Environment Variables
TSQA_LAYOUT_PREFIX: Prefix to create layouts for each test execution (defaults to /tmp)
TSQA_LOG_LEVEL: Log level for TSQA (defaults to INFO)
TSQA_TMP_DIR: temp directory for building of source (environment factory)
+
+
+====
+TODO
+====
+- abstract out "daemon" from environment. This will make it more generic (less ATS specific)and make it easy to wrap commands in other commands (such as valgrind)
[05/50] trafficserver-qa git commit: Cleanup interface for default
environment case
Posted by jp...@apache.org.
Cleanup interface for default environment case
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/6545cc17
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/6545cc17
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/6545cc17
Branch: refs/heads/master
Commit: 6545cc177b23d31ef8080d7718a66586bac40473
Parents: 9d29420
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Dec 22 18:01:35 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Dec 22 18:01:35 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/6545cc17/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index da73ffa..89ad203 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -20,13 +20,39 @@ class EnvironmentCase(unittest.TestCase):
# call parent constructor
super(EnvironmentCase, cls).setUpClass()
+ # get an environment
+ cls.environment = cls.getEnv()
+
+ # call env setup, so people can change configs etc
+ cls.setUpEnv()
+
+ # start ATS
+ cls.environment.start()
+
+ @classmethod
+ def getEnv(cls):
+ '''
+ This function is responsible for returning an environment. The default
+ is to build ATS and return a copy of an environment
+ '''
SOURCE_DIR = os.getenv('TSQA_SRC_DIR', '~/trafficserver')
TMP_DIR = os.getenv('TSQA_TMP_DIR','/tmp/tsqa')
ef = tsqa.environment.EnvironmentFactory(SOURCE_DIR, os.path.join(TMP_DIR, 'base_envs'))
- cls.environment = ef.get_environment()
+ return ef.get_environment()
+
+ @classmethod
+ def setUpEnv(cls):
+ '''
+ This funciton is responsible for setting up the environment for this fixture
+ This includes everything pre-daemon start
+ '''
+ pass
@classmethod
def tearDownClass(cls):
+ # stop ATS
+ cls.environment.stop()
+
# call parent destructor
super(EnvironmentCase, cls).tearDownClass()
cls.environment.destroy() # this will tear down any processes that we started
[25/50] trafficserver-qa git commit: Add log
Posted by jp...@apache.org.
Add log
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/b1272f3f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/b1272f3f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/b1272f3f
Branch: refs/heads/master
Commit: b1272f3fa0382c8c5140e11eae921e56a4a4ff64
Parents: adc6aab
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Jan 6 18:15:22 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Jan 6 18:15:22 2015 -0800
----------------------------------------------------------------------
tsqa/log.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/b1272f3f/tsqa/log.py
----------------------------------------------------------------------
diff --git a/tsqa/log.py b/tsqa/log.py
new file mode 100644
index 0000000..edfd0b7
--- /dev/null
+++ b/tsqa/log.py
@@ -0,0 +1,12 @@
+import logging
+import os
+
+logging.root.setLevel(os.environ.get('TSQA_LOG_LEVEL', logging.INFO))
+handler = logging.StreamHandler()
+handler.setLevel(os.environ.get('TSQA_LOG_LEVEL', logging.INFO))
+handler.setFormatter(logging.Formatter("%(levelname)s %(asctime)-15s - %(message)s"))
+logging.root.addHandler(handler)
+
+# quiet a few loggers...
+logging.getLogger('urllib3').setLevel(logging.CRITICAL)
+logging.getLogger('requests').setLevel(logging.WARNING)
[26/50] trafficserver-qa git commit: Support files in the layout root
Posted by jp...@apache.org.
Support files in the layout root
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/aa999b54
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/aa999b54
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/aa999b54
Branch: refs/heads/master
Commit: aa999b5494af1f295b0bfb5b7d51543994497dc3
Parents: b1272f3
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Jan 6 18:15:36 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Jan 6 18:15:36 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/aa999b54/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 24d432f..fb97bc7 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -284,11 +284,16 @@ class Environment:
# copy all files from old layout to new one
for item in os.listdir(layout.prefix):
- shutil.copytree(os.path.join(layout.prefix, item),
- os.path.join(self.layout.prefix, item),
- symlinks=True,
- ignore=None,
- )
+ src_path = os.path.join(layout.prefix, item)
+ dst_path = os.path.join(self.layout.prefix, item)
+ if os.path.isdir(src_path):
+ shutil.copytree(src_path,
+ dst_path,
+ symlinks=True,
+ ignore=None,
+ )
+ elif os.path.isfile(src_path):
+ shutil.copyfile(src_path, dst_path)
# make sure that all suffixes in new layout exist
for name in self.layout.suffixes:
[48/50] trafficserver-qa git commit: Switch back to traffic_server
for now
Posted by jp...@apache.org.
Switch back to traffic_server for now
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/6c5e66c4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/6c5e66c4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/6c5e66c4
Branch: refs/heads/master
Commit: 6c5e66c41736a2c0259bd705d417513e8a4089f8
Parents: 8987fca
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 23 15:43:57 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 23 15:43:57 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/6c5e66c4/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index c1eafd6..e1bf9fa 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -234,8 +234,11 @@ class Environment:
return environ
def __exec_cop(self):
- path = os.path.join(self.layout.bindir, 'traffic_cop')
- cmd = [path, '--debug', '--stdout']
+ # TODO: re-enable after jpeach's patch lands to fix proxy.config.admin.user_id
+ #path = os.path.join(self.layout.bindir, 'traffic_cop')
+ #cmd = [path, '--debug', '--stdout']
+
+ cmd = [os.path.join(self.layout.bindir, 'traffic_server')]
with open(os.path.join(self.layout.logdir, 'cop.log'), 'w+') as logfile:
self.cop = subprocess.Popen(cmd,
@@ -325,8 +328,9 @@ class Environment:
admin_port = tsqa.utils.bind_unused_port()[1]
self.hostports = [('127.0.0.1', http_server_port),
- ('127.0.0.1', manager_mgmt_port),
- ('127.0.0.1', admin_port),
+ # TODO: re-enable after jpeach's patch lands to fix proxy.config.admin.user_id
+ #('127.0.0.1', manager_mgmt_port),
+ #('127.0.0.1', admin_port),
]
# overwrite a few things that need to be changed to have a unique env
@@ -342,7 +346,7 @@ class Environment:
'proxy.config.process_manager.mgmt_port': manager_mgmt_port, # your own listen port
'proxy.config.admin.autoconf_port': admin_port,
'proxy.config.diags.show_location': 1,
- 'proxy.config.admin.user_id': '#-1',
+ #'proxy.config.admin.user_id': '#-1',
# set the process_server timeouts to 0 (faster startup)
'proxy.config.lm.pserver_timeout_secs': 0,
[38/50] trafficserver-qa git commit: Add '_' to blacklisted env vars
Posted by jp...@apache.org.
Add '_' to blacklisted env vars
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/1ceb4382
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/1ceb4382
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/1ceb4382
Branch: refs/heads/master
Commit: 1ceb4382d3709c872a37fa411cd56b496240376c
Parents: 01f56d5
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 16 19:17:12 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 16 19:17:12 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/1ceb4382/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 34e0984..0e0173a 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -121,7 +121,7 @@ class EnvironmentFactory(object):
# TODO: only de-dupe for get_key?? for now we don't care since all of these
# have no effect on build, but if we add one that does we'll care
# TODO: global?
- for blacklisted_key in ('PWD', 'OLDPWD', 'LD_LIBRARY_PATH', 'TS_ROOT'):
+ for blacklisted_key in ('PWD', 'OLDPWD', 'LD_LIBRARY_PATH', 'TS_ROOT', '_'):
if blacklisted_key in env:
del env[blacklisted_key]
[22/50] trafficserver-qa git commit: Misc logging cleanup
Posted by jp...@apache.org.
Misc logging cleanup
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/71fa4c14
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/71fa4c14
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/71fa4c14
Branch: refs/heads/master
Commit: 71fa4c145fdf6a06e895033dd16b888ea711019c
Parents: 673d4df
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Jan 5 19:02:49 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Jan 5 19:02:49 2015 -0800
----------------------------------------------------------------------
tsqa/__init__.py | 2 ++
tsqa/environment.py | 12 ++++++---
tsqa/test_cases.py | 5 ++--
tsqa/utils.py | 70 ++++--------------------------------------------
4 files changed, 18 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/71fa4c14/tsqa/__init__.py
----------------------------------------------------------------------
diff --git a/tsqa/__init__.py b/tsqa/__init__.py
index e69de29..92492c8 100644
--- a/tsqa/__init__.py
+++ b/tsqa/__init__.py
@@ -0,0 +1,2 @@
+# initialize logger
+import tsqa.log
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/71fa4c14/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 03c1396..7574930 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -4,11 +4,11 @@ import os
import copy
import shutil
import tsqa.utils
-import logging
import sys
import tsqa.configs
import tsqa.utils
+import logging
class EnvironmentFactory(object):
@@ -29,7 +29,7 @@ class EnvironmentFactory(object):
# TODO: ensure this directory exists? (and is git?)
self.source_dir = source_dir
- self.log = tsqa.utils.get_logger()
+ self.log = logging.getLogger(__name__)
self.env_cache_dir = env_cache_dir # base directory for environment caching
if default_configure is not None:
@@ -187,7 +187,7 @@ class Layout:
def __init__(self, prefix):
self.prefix = prefix
- self.log = tsqa.utils.get_logger()
+ self.log = logging.getLogger(__name__)
def __getattr__(self, name):
# Raise an error for suffixes we don't know about
@@ -252,7 +252,7 @@ class Environment:
"""
Initialize a new Environment.
"""
- self.log = tsqa.utils.get_logger()
+ self.log = logging.getLogger(__name__)
self.cop = None
self.hostports = []
if layout:
@@ -329,6 +329,8 @@ class Environment:
self.layout = Layout(None)
def start(self):
+ if self.running(): # if its already running, don't start another one
+ raise Exception('traffic cop already started')
self.log.debug("Starting traffic cop")
assert(os.path.isfile(os.path.join(self.layout.sysconfdir, 'records.config')))
self.__exec_cop()
@@ -343,6 +345,8 @@ class Environment:
self.cop.terminate() # TODO: remove?? or wait...
def running(self):
+ if self.cop is None:
+ return False
self.cop.poll()
return self.cop is not None and self.cop.returncode is not None # its running if it hasn't died
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/71fa4c14/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index cb1ef55..87885b0 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -1,6 +1,7 @@
'''
Some base test cases that do environment handling for you
'''
+import logging
import tsqa.endpoint
import tsqa.environment
@@ -25,7 +26,7 @@ class EnvironmentCase(unittest.TestCase):
super(EnvironmentCase, cls).setUpClass()
# get a logger
- cls.log = tsqa.utils.get_logger()
+ cls.log = logging.getLogger(__name__)
# get an environment
cls.environment = cls.getEnv()
@@ -93,7 +94,7 @@ class DynamicHTTPEndpointCase(unittest.TestCase):
@classmethod
def setUpClass(cls, port=0):
# get a logger
- cls.log = tsqa.utils.get_logger()
+ cls.log = logging.getLogger(__name__)
cls.http_endpoint = tsqa.endpoint.DynamicHTTPEndpoint(port=port)
cls.http_endpoint.start()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/71fa4c14/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index d522f66..4f63a2a 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -4,68 +4,11 @@ import json
import sys
import subprocess
import socket
-import logging
import time
-tsqa_logger = None
-tsqa_log_level = logging.INFO
-tsqa_log_levels = {
- 'CRITICAL': logging.CRITICAL,
- 'ERROR': logging.ERROR,
- 'WARN': logging.WARNING,
- 'WARNING': logging.WARNING,
- 'INFO': logging.INFO,
- 'DEBUG': logging.DEBUG,
- 'NOTSET': logging.NOTSET
-}
-
-def set_log_level(log_level):
- '''
- Set the global log level (override with env var TSQA_LOG_LEVEL). Must be called
- before first get_logger()
- '''
-
- global tsqa_log_level
- tsqa_log_level = log_level
-
-def get_log_level():
- '''
- Get the global log level (override with env var TSQA_LOG_LEVEL).
- '''
-
- if os.environ.has_key('TSQA_LOG_LEVEL'):
- log_level = os.environ['TSQA_LOG_LEVEL'].upper()
-
- if tsqa_log_levels.has_key(log_level):
- return tsqa_log_levels[log_level]
-
- return tsqa_log_level
-
-def set_logger(logger):
- '''
- Set/replace the global logger
- '''
-
- global tsqa_logger
- tsqa_logger = logger
-
-def get_logger():
- '''
- Get the global logger
- '''
-
- global tsqa_logger
-
- if tsqa_logger:
- return tsqa_logger
-
- tsqa_logger = logging.getLogger()
- tsqa_logger.setLevel(get_log_level())
- handler = logging.StreamHandler()
- handler.setFormatter(logging.Formatter("%(levelname)s %(asctime)-15s - %(message)s"))
- tsqa_logger.addHandler(handler)
+import logging
- return tsqa_logger
+log = logging.getLogger(__name__)
def poll_interfaces(hostports, **kwargs):
''' Block until we can successfully connect to all ports or timeout
@@ -89,8 +32,7 @@ def poll_interfaces(hostports, **kwargs):
hostname = hostport[0]
port = hostport[1]
- if get_logger().isEnabledFor(logging.DEBUG):
- get_logger().debug("Checking interface '%s:%d'", hostname, port)
+ log.debug("Checking interface '%s:%d'", hostname, port)
# This supports IPv6
@@ -99,8 +41,7 @@ def poll_interfaces(hostports, **kwargs):
s.close()
hostports.remove(hostport)
- if get_logger().isEnabledFor(logging.DEBUG):
- get_logger().debug("Interface '%s:%d' is up", hostname, port)
+ log.debug("Interface '%s:%d' is up", hostname, port)
except:
pass
@@ -113,8 +54,7 @@ def poll_interfaces(hostports, **kwargs):
raise Exception("Timeout waiting for interfaces: {0}".format(
reduce(lambda x, y: str(x) + ',' + str(y), hostports)))
- if get_logger().isEnabledFor(logging.DEBUG):
- get_logger().debug("All interfaces are up")
+ log.debug("All interfaces are up")
# TODO: test
def import_unittest():
[24/50] trafficserver-qa git commit: Cleanup
Posted by jp...@apache.org.
Cleanup
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/adc6aab3
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/adc6aab3
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/adc6aab3
Branch: refs/heads/master
Commit: adc6aab343ea2432d47b902ae6fdd60d5babbf05
Parents: 04c3ab6
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Jan 6 14:57:19 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Jan 6 14:57:19 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 6 +++---
tsqa/test_cases.py | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/adc6aab3/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 7574930..24d432f 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -243,7 +243,6 @@ class Environment:
)
tsqa.utils.poll_interfaces(self.hostports)
- # TODO: better checking...
self.cop.poll()
if self.cop.returncode is not None:
raise Exception(self.cop.returncode, self.layout.prefix)
@@ -254,6 +253,7 @@ class Environment:
"""
self.log = logging.getLogger(__name__)
self.cop = None
+ # TODO: parse config? Don't like the separate hostports...
self.hostports = []
if layout:
self.layout = layout
@@ -336,8 +336,8 @@ class Environment:
self.__exec_cop()
self.log.debug("Started traffic cop: %s", self.cop)
+ # TODO: exception if already stopped?
# TODO: more graceful stop?
- # TODO: raise exception when you call stop when its not started?
def stop(self):
self.log.debug("Killing traffic cop: %s", self.cop)
if self.cop is not None:
@@ -348,7 +348,7 @@ class Environment:
if self.cop is None:
return False
self.cop.poll()
- return self.cop is not None and self.cop.returncode is not None # its running if it hasn't died
+ return self.cop.returncode is not None # its running if it hasn't died
# TODO: only do this on success, instead of __del__?
def __del__(self):
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/adc6aab3/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 9ee81f9..e4d7490 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -79,7 +79,6 @@ class EnvironmentCase(unittest.TestCase):
if cls.environment.cop is not None and not cls.environment.running:
raise Exception('ATS died during the test run')
# stop ATS
-
cls.environment.stop()
# call parent destructor
[11/50] trafficserver-qa git commit: Revamp records config object,
need support for multiple top_kinds
Posted by jp...@apache.org.
Revamp records config object, need support for multiple top_kinds
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/ccda9f0d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/ccda9f0d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/ccda9f0d
Branch: refs/heads/master
Commit: ccda9f0df3e8b87ce94babe6ca7441e50ec8f7cb
Parents: f16c79a
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 11:13:06 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 11:13:23 2014 -0800
----------------------------------------------------------------------
tsqa/configs.py | 39 +++++++++++++++++++++++++++------------
tsqa/environment.py | 2 +-
2 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/ccda9f0d/tsqa/configs.py
----------------------------------------------------------------------
diff --git a/tsqa/configs.py b/tsqa/configs.py
index 51f563f..2a4cc3e 100644
--- a/tsqa/configs.py
+++ b/tsqa/configs.py
@@ -23,6 +23,11 @@ class Config(object):
class RecordsConfig(Config, dict):
'''
Create a "dict" representation of records.config
+
+ This can be accessed as a multi-level dictionary
+
+ such as:
+ rc['CONFIG']['proxy.config.log.hostname']
'''
kind_map = {'STRING': str,
'INT': int,
@@ -34,7 +39,7 @@ class RecordsConfig(Config, dict):
float: 'FLOAT',
}
- line_template = 'CONFIG {name} {kind} {val}\n'
+ line_template = '{top_kind} {name} {kind} {val}\n'
def __init__(self, filename):
dict.__init__(self)
@@ -43,20 +48,30 @@ class RecordsConfig(Config, dict):
self.load()
def load(self):
- self._config = {}
with open(self.filename, 'r') as fh:
for line in fh:
line = line.strip()
# skip comments
- if line.startswith('#'):
+ if not line or line.startswith('#'):
continue
- _, name, kind, val = line.split(' ', 3)
- self[name] = self.kind_map[kind](val)
-
- def write(self, dest):
- with open(dest, 'w') as fh:
- for name, val in self.iteritems():
- fh.write(self.line_template.format(name=name,
- kind=self.reverse_kind_map[type(val)],
- val=val))
+ top_kind, name, kind, val = line.split(' ', 3)
+ if top_kind not in self:
+ self[top_kind] = {}
+ self[top_kind][name] = self.kind_map[kind](val)
+
+ def write(self):
+ with open(self.filename, 'w') as fh:
+ for top_kind, config_map in self.iteritems():
+ for name, val in config_map.iteritems():
+ fh.write(self.line_template.format(top_kind=top_kind,
+ name=name,
+ kind=self.reverse_kind_map[type(val)],
+ val=val))
+
+if __name__ == '__main__':
+ rc = RecordsConfig('/etc/trafficserver/records.config')
+ rc['CONFIG']['proxy.config.log.hostname']
+ rc['CONFIG'].update({'proxy.config.log.hostname': 'foo'})
+ rc.filename = '/tmp/recordstest.config'
+ rc.write()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/ccda9f0d/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 314fdab..23970df 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -304,7 +304,7 @@ class Environment:
installed files.
"""
self.stop()
- #shutil.rmtree(self.layout.prefix, ignore_errors=True)
+ shutil.rmtree(self.layout.prefix, ignore_errors=True)
self.layout = Layout(None)
def start(self):
[20/50] trafficserver-qa git commit: Replaced sleeps with port
polling.
Posted by jp...@apache.org.
Replaced sleeps with port polling.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/a502d378
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/a502d378
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/a502d378
Branch: refs/heads/master
Commit: a502d378bd9eca7df0c9b1107d5d789bdbd5da81
Parents: 32fc37c
Author: Joshua Blatt <bl...@yahoo-inc.com>
Authored: Mon Dec 29 11:04:51 2014 -0800
Committer: Joshua Blatt <bl...@yahoo-inc.com>
Committed: Mon Dec 29 11:04:51 2014 -0800
----------------------------------------------------------------------
tests/hello_world_test.py | 10 ++--
tsqa/environment.py | 79 +++++++++++++++------------
tsqa/test_cases.py | 8 ++-
tsqa/utils.py | 118 ++++++++++++++++++++++++++++++++++++++++-
4 files changed, 175 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/a502d378/tests/hello_world_test.py
----------------------------------------------------------------------
diff --git a/tests/hello_world_test.py b/tests/hello_world_test.py
index 2d918ea..302e4b2 100644
--- a/tests/hello_world_test.py
+++ b/tests/hello_world_test.py
@@ -22,22 +22,24 @@ class TestEnvironmentCase(tsqa.test_cases.EnvironmentCase):
# TODO: actually test this, this is currently terrible ;)
def test_daemon(self):
- self.environment.start() # start ATS
- time.sleep(2)
+ self.log.info('Begin test_daemon')
assert self.environment.cop.pid > 0
assert self.environment.cop.returncode is None
- self.environment.stop()
+ self.log.info('End test_daemon')
class TestDynamicHTTPEndpointCase(tsqa.test_cases.DynamicHTTPEndpointCase):
def test_base(self):
+ self.log.info('Begin test_base')
ret = requests.get(self.endpoint_url('/footest'))
self.assertEqual(ret.status_code, 404)
+ self.log.info('End test_base')
def test_endpoint_url(self):
+ self.log.info('Begin test_endpoint_url')
assert self.endpoint_url() == 'http://127.0.0.1:{0}'.format(self.http_endpoint.address[1])
assert self.endpoint_url('/foo') == 'http://127.0.0.1:{0}/foo'.format(self.http_endpoint.address[1])
-
+ self.log.info('End test_endpoint_url')
if __name__ == "__main__":
unittest.main()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/a502d378/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index cd5b747..03c1396 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -3,8 +3,9 @@ import tempfile
import os
import copy
import shutil
-import json
-
+import tsqa.utils
+import logging
+import sys
import tsqa.configs
import tsqa.utils
@@ -28,7 +29,7 @@ class EnvironmentFactory(object):
# TODO: ensure this directory exists? (and is git?)
self.source_dir = source_dir
-
+ self.log = tsqa.utils.get_logger()
self.env_cache_dir = env_cache_dir # base directory for environment caching
if default_configure is not None:
@@ -45,13 +46,20 @@ class EnvironmentFactory(object):
'''
Autoreconf to make the configure script
'''
+
+ kwargs = {
+ 'cwd': self.source_dir,
+ 'env': self.default_env,
+ 'stdout': subprocess.PIPE,
+ 'stderr': subprocess.PIPE
+ }
+
+ if self.log.isEnabledFor(logging.DEBUG):
+ kwargs['stdout'] = sys.stdout.fileno()
+ kwargs['stderr'] = sys.stderr.fileno()
+
# run autoreconf in source tree
- tsqa.utils.run_sync_command(['autoreconf', '-if'],
- cwd=self.source_dir,
- env=self.default_env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['autoreconf', '-if'], **kwargs)
@property
def source_hash(self):
@@ -114,39 +122,34 @@ class EnvironmentFactory(object):
del env[blacklisted_key]
key = self._get_key(configure, env)
- # TODO: remove
- print 'Key is:', key, 'args are:', configure, env
+ self.log.debug('Key is: %s, args are: %s %s' % (key, configure, env))
# if we don't have it built already, lets build it
if key not in self.environment_stash:
self.autoreconf()
builddir = tempfile.mkdtemp()
+ kwargs = {
+ 'cwd': builddir,
+ 'env': env,
+ 'stdout': subprocess.PIPE,
+ 'stderr': subprocess.PIPE
+ }
+
+ if self.log.isEnabledFor(logging.DEBUG):
+ kwargs['stdout'] = sys.stdout.fileno()
+ kwargs['stderr'] = sys.stderr.fileno()
+
# configure
args = [os.path.join(self.source_dir, 'configure'), '--prefix=/'] + tsqa.utils.configure_list(configure)
- tsqa.utils.run_sync_command(args,
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(args, **kwargs)
# make
- tsqa.utils.run_sync_command(['make', '-j'],
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['make', '-j'], **kwargs)
installdir = tempfile.mkdtemp(dir=self.env_cache_dir)
# make install
- tsqa.utils.run_sync_command(['make', 'install', 'DESTDIR={0}'.format(installdir)],
- cwd=builddir,
- env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ tsqa.utils.run_sync_command(['make', 'install', 'DESTDIR={0}'.format(installdir)], **kwargs)
shutil.rmtree(builddir) # delete builddir, not useful after install
# stash the env
@@ -184,6 +187,7 @@ class Layout:
def __init__(self, prefix):
self.prefix = prefix
+ self.log = tsqa.utils.get_logger()
def __getattr__(self, name):
# Raise an error for suffixes we don't know about
@@ -237,8 +241,8 @@ class Environment:
stdout=logfile,
stderr=logfile,
)
- import time
- time.sleep(3) # TODO: wait or the process to listen?
+ tsqa.utils.poll_interfaces(self.hostports)
+
# TODO: better checking...
self.cop.poll()
if self.cop.returncode is not None:
@@ -248,7 +252,9 @@ class Environment:
"""
Initialize a new Environment.
"""
+ self.log = tsqa.utils.get_logger()
self.cop = None
+ self.hostports = []
if layout:
self.layout = layout
else:
@@ -292,6 +298,10 @@ class Environment:
else:
os.chmod(dirname, 0777)
+ http_server_port = tsqa.utils.bind_unused_port()[1]
+ manager_mgmt_port = tsqa.utils.bind_unused_port()[1]
+ self.hostports = [('127.0.0.1', http_server_port), ('127.0.0.1', manager_mgmt_port)]
+
# overwrite a few things that need to be changed to have a unique env
records = tsqa.configs.RecordsConfig(os.path.join(self.layout.sysconfdir, 'records.config'))
records['CONFIG'].update({
@@ -301,8 +311,8 @@ class Environment:
'proxy.config.bin_path': self.layout.bindir,
'proxy.config.log.logfile_dir': self.layout.logdir,
'proxy.config.local_state_dir': self.layout.runtimedir,
- 'proxy.config.http.server_ports': str(tsqa.utils.bind_unused_port()[1]), # your own listen port
- 'proxy.config.process_manager.mgmt_port': tsqa.utils.bind_unused_port()[1], # your own listen port
+ 'proxy.config.http.server_ports': str(http_server_port), # your own listen port
+ 'proxy.config.process_manager.mgmt_port': manager_mgmt_port, # your own listen port
})
records.write()
@@ -319,12 +329,15 @@ class Environment:
self.layout = Layout(None)
def start(self):
+ self.log.debug("Starting traffic cop")
assert(os.path.isfile(os.path.join(self.layout.sysconfdir, 'records.config')))
self.__exec_cop()
+ self.log.debug("Started traffic cop: %s", self.cop)
# TODO: more graceful stop?
# TODO: raise exception when you call stop when its not started?
def stop(self):
+ self.log.debug("Killing traffic cop: %s", self.cop)
if self.cop is not None:
self.cop.kill()
self.cop.terminate() # TODO: remove?? or wait...
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/a502d378/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index d7ba75a..cb1ef55 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -10,7 +10,6 @@ unittest = tsqa.utils.import_unittest()
import os
-
# Example environment case
class EnvironmentCase(unittest.TestCase):
'''
@@ -25,6 +24,9 @@ class EnvironmentCase(unittest.TestCase):
# call parent constructor
super(EnvironmentCase, cls).setUpClass()
+ # get a logger
+ cls.log = tsqa.utils.get_logger()
+
# get an environment
cls.environment = cls.getEnv()
@@ -68,6 +70,7 @@ class EnvironmentCase(unittest.TestCase):
if cls.environment.cop is not None and not cls.environment.running:
raise Exception('ATS died during the test run')
# stop ATS
+
cls.environment.stop()
# call parent destructor
@@ -89,6 +92,9 @@ class DynamicHTTPEndpointCase(unittest.TestCase):
'''
@classmethod
def setUpClass(cls, port=0):
+ # get a logger
+ cls.log = tsqa.utils.get_logger()
+
cls.http_endpoint = tsqa.endpoint.DynamicHTTPEndpoint(port=port)
cls.http_endpoint.start()
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/a502d378/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index f58a2bd..d522f66 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -4,6 +4,117 @@ import json
import sys
import subprocess
import socket
+import logging
+import time
+
+tsqa_logger = None
+tsqa_log_level = logging.INFO
+tsqa_log_levels = {
+ 'CRITICAL': logging.CRITICAL,
+ 'ERROR': logging.ERROR,
+ 'WARN': logging.WARNING,
+ 'WARNING': logging.WARNING,
+ 'INFO': logging.INFO,
+ 'DEBUG': logging.DEBUG,
+ 'NOTSET': logging.NOTSET
+}
+
+def set_log_level(log_level):
+ '''
+ Set the global log level (override with env var TSQA_LOG_LEVEL). Must be called
+ before first get_logger()
+ '''
+
+ global tsqa_log_level
+ tsqa_log_level = log_level
+
+def get_log_level():
+ '''
+ Get the global log level (override with env var TSQA_LOG_LEVEL).
+ '''
+
+ if os.environ.has_key('TSQA_LOG_LEVEL'):
+ log_level = os.environ['TSQA_LOG_LEVEL'].upper()
+
+ if tsqa_log_levels.has_key(log_level):
+ return tsqa_log_levels[log_level]
+
+ return tsqa_log_level
+
+def set_logger(logger):
+ '''
+ Set/replace the global logger
+ '''
+
+ global tsqa_logger
+ tsqa_logger = logger
+
+def get_logger():
+ '''
+ Get the global logger
+ '''
+
+ global tsqa_logger
+
+ if tsqa_logger:
+ return tsqa_logger
+
+ tsqa_logger = logging.getLogger()
+ tsqa_logger.setLevel(get_log_level())
+ handler = logging.StreamHandler()
+ handler.setFormatter(logging.Formatter("%(levelname)s %(asctime)-15s - %(message)s"))
+ tsqa_logger.addHandler(handler)
+
+ return tsqa_logger
+
+def poll_interfaces(hostports, **kwargs):
+ ''' Block until we can successfully connect to all ports or timeout
+
+ :param hostports:
+ :param kwargs: optional timeout_sec
+ '''
+
+ connect_timeout_sec = 1
+ poll_sleep_sec = 1
+
+ if kwargs.has_key('timeout_sec'):
+ timeout = time.time() + kwargs['timeout_sec']
+ else:
+ timeout = time.time() + 5
+
+ hostports = hostports[:] # don't modify the caller's hostports
+
+ while timeout > time.time():
+ for hostport in hostports[:]: # don't modify our hostports copy during iteration
+ hostname = hostport[0]
+ port = hostport[1]
+
+ if get_logger().isEnabledFor(logging.DEBUG):
+ get_logger().debug("Checking interface '%s:%d'", hostname, port)
+
+ # This supports IPv6
+
+ try:
+ s = socket.create_connection((hostname, port), timeout=connect_timeout_sec)
+ s.close()
+ hostports.remove(hostport)
+
+ if get_logger().isEnabledFor(logging.DEBUG):
+ get_logger().debug("Interface '%s:%d' is up", hostname, port)
+ except:
+ pass
+
+ if not hostports:
+ break
+
+ time.sleep(poll_sleep_sec)
+
+ if hostports:
+ raise Exception("Timeout waiting for interfaces: {0}".format(
+ reduce(lambda x, y: str(x) + ',' + str(y), hostports)))
+
+ if get_logger().isEnabledFor(logging.DEBUG):
+ get_logger().debug("All interfaces are up")
# TODO: test
def import_unittest():
@@ -37,9 +148,12 @@ def run_sync_command(*args, **kwargs):
p = subprocess.Popen(*args, **kwargs)
stdout, stderr = p.communicate()
if p.returncode != 0:
- raise Exception('Error running: {0}\n{1}'.format(args[0], stderr))
- return stdout, stderr
+ if stderr:
+ raise Exception('Error {0} running: {1}\n{2}'.format(p.returncode, args[0], stderr))
+ else:
+ raise Exception('Error {0} running: {1}'.format(p.returncode, args[0]))
+ return stdout, stderr
def merge_dicts(*args):
'''
[34/50] trafficserver-qa git commit: Fix bug, negative logic :(
Posted by jp...@apache.org.
Fix bug, negative logic :(
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/43abdb07
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/43abdb07
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/43abdb07
Branch: refs/heads/master
Commit: 43abdb0708654ab4dc634a2a11b54517a2c42406
Parents: 84280a8
Author: Thomas Jackson <ja...@gmail.com>
Authored: Wed Jan 14 16:29:26 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Wed Jan 14 16:29:26 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/43abdb07/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index efe0c1b..3deb224 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -353,7 +353,7 @@ class Environment:
if self.cop is None:
return False
self.cop.poll()
- return self.cop.returncode is not None # its running if it hasn't died
+ return self.cop.returncode is None # its running if it hasn't died
if __name__ == '__main__':
[36/50] trafficserver-qa git commit: fix typo
Posted by jp...@apache.org.
fix typo
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9def2fb9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9def2fb9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9def2fb9
Branch: refs/heads/master
Commit: 9def2fb97b17b88357c2969d9aaf3242008a8cd4
Parents: bf84255
Author: kangli <ka...@yahoo-inc.com>
Authored: Thu Jan 15 08:49:14 2015 +0000
Committer: kangli <ka...@yahoo-inc.com>
Committed: Thu Jan 15 08:49:14 2015 +0000
----------------------------------------------------------------------
tsqa/test_cases.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9def2fb9/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 35319a8..a5e6e2e 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -23,7 +23,7 @@ class EnvironmentCase(unittest.TestCase):
def run(self, result=None):
unittest.TestCase.run(self, result)
- self.__successful &= result.result.wasSuccessful()
+ self.__successful &= result.wasSuccessful()
@classmethod
def setUpClass(cls):
[32/50] trafficserver-qa git commit: For all paths that are added in
the default endpoint
Posted by jp...@apache.org.
For all paths that are added in the default endpoint
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/5044dd41
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/5044dd41
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/5044dd41
Branch: refs/heads/master
Commit: 5044dd418a70788caa7d704017f18258578ce567
Parents: 733ed1b
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Jan 12 10:52:18 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Jan 12 10:52:18 2015 -0800
----------------------------------------------------------------------
tsqa/endpoint.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/5044dd41/tsqa/endpoint.py
----------------------------------------------------------------------
diff --git a/tsqa/endpoint.py b/tsqa/endpoint.py
index 9f9bc9b..1d18325 100644
--- a/tsqa/endpoint.py
+++ b/tsqa/endpoint.py
@@ -99,7 +99,7 @@ class DynamicHTTPEndpoint(threading.Thread):
return ('', 404)
# A little magic to make flask accept *all* methods on the catch_all path
- for rule in self.app.url_map.iter_rules('hello'):
+ for rule in self.app.url_map.iter_rules():
rule.methods = None
rule.refresh()
[27/50] trafficserver-qa git commit: Remove unused var
Posted by jp...@apache.org.
Remove unused var
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/3047c3c4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/3047c3c4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/3047c3c4
Branch: refs/heads/master
Commit: 3047c3c4a40aa69df7b7e00b8d9debb79abb88d2
Parents: aa999b5
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Jan 6 18:15:49 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Jan 6 18:15:49 2015 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/3047c3c4/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index e4d7490..da7f8e9 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -52,8 +52,6 @@ class EnvironmentCase(unittest.TestCase):
# start ATS
cls.environment.start()
- cls._config_cache = {}
-
@classmethod
def getEnv(cls):
'''
[33/50] trafficserver-qa git commit: Actually call the
environment.running() func
Posted by jp...@apache.org.
Actually call the environment.running() func
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/84280a83
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/84280a83
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/84280a83
Branch: refs/heads/master
Commit: 84280a83cbfa449e9c53c9fdbf21f6f6b302b20f
Parents: 5044dd4
Author: Thomas Jackson <ja...@gmail.com>
Authored: Wed Jan 14 15:57:32 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Wed Jan 14 15:57:32 2015 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/84280a83/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index 3fe70af..35319a8 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -35,6 +35,7 @@ class EnvironmentCase(unittest.TestCase):
# get an environment
cls.environment = cls.getEnv()
+ # TODO: better... I dont think this output is captured in each test run
logging.info('Environment prefix is {0}'.format(cls.environment.layout.prefix))
cfg_dir = os.path.join(cls.environment.layout.prefix, 'etc', 'trafficserver')
@@ -82,7 +83,7 @@ class EnvironmentCase(unittest.TestCase):
@classmethod
def tearDownClass(cls):
- if not cls.environment.running:
+ if not cls.environment.running():
raise Exception('ATS died during the test run')
# stop ATS
cls.environment.stop()
[39/50] trafficserver-qa git commit: Add TCP socket servers
Posted by jp...@apache.org.
Add TCP socket servers
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/498fdda5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/498fdda5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/498fdda5
Branch: refs/heads/master
Commit: 498fdda5b3155d8d9a7c7d2d9c850d22826d942b
Parents: 1ceb438
Author: Thomas Jackson <ja...@gmail.com>
Authored: Wed Jan 21 18:54:50 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Wed Jan 21 18:54:50 2015 -0800
----------------------------------------------------------------------
tsqa/endpoint.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 86 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/498fdda5/tsqa/endpoint.py
----------------------------------------------------------------------
diff --git a/tsqa/endpoint.py b/tsqa/endpoint.py
index 1d18325..80ff841 100644
--- a/tsqa/endpoint.py
+++ b/tsqa/endpoint.py
@@ -4,7 +4,8 @@ import os
import threading
import requests
import flask
-
+import SocketServer
+import ssl
from collections import defaultdict
from wsgiref.simple_server import make_server
@@ -153,3 +154,87 @@ class DynamicHTTPEndpoint(threading.Thread):
self.ready.set()
# serve it
self.server.serve_forever()
+
+
+class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
+ pass
+
+
+class SocketServerDaemon(threading.Thread):
+ '''
+ A daemon thread to run a socketserver
+ '''
+ def __init__(self, handler, port=0):
+ threading.Thread.__init__(self)
+ self.port = port
+ self.handler = handler
+ self.ready = threading.Event()
+ self.daemon = True
+
+ def run(self):
+ self.server = ThreadedTCPServer(('0.0.0.0', self.port), self.handler)
+ self.server.allow_reuse_address = True
+ self.port = self.server.socket.getsockname()[1]
+
+ self.ready.set()
+
+ # Activate the server; this will keep running until you
+ # interrupt the program with Ctrl-C
+ self.server.serve_forever()
+
+
+class ThreadedSSLTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
+ def __init__(self,
+ server_address,
+ RequestHandlerClass,
+ certfile,
+ keyfile,
+ ssl_version=ssl.PROTOCOL_TLSv1,
+ bind_and_activate=True):
+ SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate)
+ self.certfile = certfile
+ self.keyfile = keyfile
+ self.ssl_version = ssl_version
+
+ def get_request(self):
+ newsocket, fromaddr = self.socket.accept()
+ connstream = ssl.wrap_socket(newsocket,
+ server_side=True,
+ certfile=self.certfile,
+ keyfile=self.keyfile,
+ ssl_version=self.ssl_version,
+ )
+ return connstream, fromaddr
+
+class SSLSocketServerDaemon(threading.Thread):
+ '''
+ A daemon thread to run a socketserver
+ '''
+ def __init__(self, handler, cert, key, port=0):
+ # TODO: nicer import?
+ import requests
+ requests.packages.urllib3.disable_warnings()
+
+ threading.Thread.__init__(self)
+ self.handler = handler
+ self.cert = cert
+ self.key = key
+ self.port = port
+
+ self.ready = threading.Event()
+ self.daemon = True
+
+ def run(self):
+ self.server = ThreadedSSLTCPServer(('0.0.0.0', self.port),
+ self.handler,
+ self.cert,
+ self.key,
+ )
+ self.server.allow_reuse_address = True
+ self.port = self.server.socket.getsockname()[1]
+
+ self.ready.set()
+
+ # Activate the server; this will keep running until you
+ # interrupt the program with Ctrl-C
+ self.server.serve_forever()
[46/50] trafficserver-qa git commit: Cleanup logging
Posted by jp...@apache.org.
Cleanup logging
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/015ef82f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/015ef82f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/015ef82f
Branch: refs/heads/master
Commit: 015ef82f06b179ca85c4f018140243a0da57edf8
Parents: b7fd08b
Author: Thomas Jackson <ja...@gmail.com>
Authored: Fri Jan 23 15:08:51 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Fri Jan 23 15:08:51 2015 -0800
----------------------------------------------------------------------
tsqa/environment.py | 15 ++++++---------
tsqa/utils.py | 1 +
2 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/015ef82f/tsqa/environment.py
----------------------------------------------------------------------
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 70300ee..c1eafd6 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -31,7 +31,6 @@ class EnvironmentFactory(object):
# TODO: ensure this directory exists? (and is git?)
self.source_dir = source_dir
- self.log = logging.getLogger(__name__)
self.env_cache_dir = env_cache_dir # base directory for environment caching
if default_configure is not None:
@@ -55,7 +54,7 @@ class EnvironmentFactory(object):
'stderr': subprocess.PIPE
}
- if self.log.isEnabledFor(logging.DEBUG):
+ if log.isEnabledFor(logging.DEBUG):
kwargs['stdout'] = sys.stdout.fileno()
kwargs['stderr'] = sys.stderr.fileno()
@@ -124,7 +123,7 @@ class EnvironmentFactory(object):
env_key[whitelisted_key] = env.get(whitelisted_key)
key = self._get_key(configure, env_key)
- self.log.debug('Key is: %s, args are: %s %s' % (key, configure, env_key))
+ log.debug('Key is: %s, args are: %s %s' % (key, configure, env_key))
# if we don't have it built already, lets build it
if key not in self.environment_stash:
@@ -138,7 +137,7 @@ class EnvironmentFactory(object):
'stderr': subprocess.PIPE
}
- if self.log.isEnabledFor(logging.DEBUG):
+ if log.isEnabledFor(logging.DEBUG):
kwargs['stdout'] = sys.stdout.fileno()
kwargs['stderr'] = sys.stderr.fileno()
@@ -191,7 +190,6 @@ class Layout:
def __init__(self, prefix):
self.prefix = prefix
- self.log = logging.getLogger(__name__)
def __getattr__(self, name):
# Raise an error for suffixes we don't know about
@@ -262,7 +260,6 @@ class Environment:
"""
Initialize a new Environment.
"""
- self.log = logging.getLogger(__name__)
self.cop = None
# TODO: parse config? Don't like the separate hostports...
self.hostports = []
@@ -378,15 +375,15 @@ class Environment:
def start(self):
if self.running(): # if its already running, don't start another one
raise Exception('traffic cop already started')
- self.log.debug("Starting traffic cop")
+ log.debug("Starting traffic cop")
assert(os.path.isfile(os.path.join(self.layout.sysconfdir, 'records.config')))
self.__exec_cop()
- self.log.debug("Started traffic cop: %s", self.cop)
+ log.debug("Started traffic cop: %s", self.cop)
# TODO: exception if already stopped?
# TODO: more graceful stop?
def stop(self):
- self.log.debug("Killing traffic cop: %s", self.cop)
+ log.debug("Killing traffic cop: %s", self.cop)
if self.cop is not None:
self.cop.kill()
self.cop.terminate() # TODO: remove?? or wait...
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/015ef82f/tsqa/utils.py
----------------------------------------------------------------------
diff --git a/tsqa/utils.py b/tsqa/utils.py
index 28f9e45..1878738 100644
--- a/tsqa/utils.py
+++ b/tsqa/utils.py
@@ -6,6 +6,7 @@ import subprocess
import socket
import time
+import tsqa.log
import logging
log = logging.getLogger(__name__)
[14/50] trafficserver-qa git commit: Clean up interface to configs
Posted by jp...@apache.org.
Clean up interface to configs
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/03de0c42
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/03de0c42
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/03de0c42
Branch: refs/heads/master
Commit: 03de0c423b6d754748845f05e4980bd93c2324fb
Parents: fcbbd78
Author: Thomas Jackson <ja...@gmail.com>
Authored: Tue Dec 23 13:57:20 2014 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Tue Dec 23 13:57:20 2014 -0800
----------------------------------------------------------------------
tsqa/test_cases.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/03de0c42/tsqa/test_cases.py
----------------------------------------------------------------------
diff --git a/tsqa/test_cases.py b/tsqa/test_cases.py
index a6a5820..88e6e60 100644
--- a/tsqa/test_cases.py
+++ b/tsqa/test_cases.py
@@ -24,6 +24,13 @@ class EnvironmentCase(unittest.TestCase):
# get an environment
cls.environment = cls.getEnv()
+ cfg_dir = os.path.join(cls.environment.layout.prefix, 'etc', 'trafficserver')
+
+ # create a bunch of config objects that people can access/modify
+ cls.configs = {
+ 'records.config': tsqa.configs.RecordsConfig(os.path.join(cfg_dir, 'records.config'))
+ }
+
# call env setup, so people can change configs etc
cls.setUpEnv(cls.environment)
@@ -32,13 +39,6 @@ class EnvironmentCase(unittest.TestCase):
cls._config_cache = {}
- @property
- def records_config(self):
- if 'records.config' not in self._config_cache:
- cfg_dir = os.path.join(self.environment.layout.prefix, 'etc', 'trafficserver')
- self._config_cache['records.config'] = tsqa.configs.RecordsConfig(os.path.join(cfg_dir, 'records.config'))
- return self._config_cache['records.config']
-
@classmethod
def getEnv(cls):
'''
[21/50] trafficserver-qa git commit: Merge pull request #2 from
duderino/master
Posted by jp...@apache.org.
Merge pull request #2 from duderino/master
Added logging (python logging module) and replace sleeps with port polling
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/673d4df9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/673d4df9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/673d4df9
Branch: refs/heads/master
Commit: 673d4df968a428cf7c4f65d8659910d456b1307b
Parents: 32fc37c a502d37
Author: Thomas Jackson <ja...@gmail.com>
Authored: Mon Jan 5 18:18:49 2015 -0800
Committer: Thomas Jackson <ja...@gmail.com>
Committed: Mon Jan 5 18:18:49 2015 -0800
----------------------------------------------------------------------
tests/hello_world_test.py | 10 ++--
tsqa/environment.py | 79 +++++++++++++++------------
tsqa/test_cases.py | 8 ++-
tsqa/utils.py | 118 ++++++++++++++++++++++++++++++++++++++++-
4 files changed, 175 insertions(+), 40 deletions(-)
----------------------------------------------------------------------