From 31f0f7ad7e5584883bca555970c61036983e4c23 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 12 Sep 2013 17:28:50 -0500 Subject: [PATCH] Fix get_http_log_path(), update callers, add tests --- teuthology/misc.py | 9 ++++++++- teuthology/suite.py | 2 +- teuthology/test/test_misc.py | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 0d154b5fadc31..f5a4e44c264ae 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -53,7 +53,14 @@ def get_http_log_path(archive_dir, job_id=None): http_base = config.archive_server if not http_base: return None - archive_subdir = os.path.split(archive_dir)[-1] + + sep = os.path.sep + archive_subdir = archive_dir.split(sep)[-1] + if archive_subdir.endswith(str(job_id)): + archive_subdir = archive_dir.split(sep)[-2] + + print archive_subdir + if job_id is None: return os.path.join(http_base, archive_subdir, '') return os.path.join(http_base, archive_subdir, str(job_id), '') diff --git a/teuthology/suite.py b/teuthology/suite.py index 1c9e571243a1e..d6f0abe3ad171 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -593,7 +593,7 @@ def build_email_body(name, archive_dir, timeout): body = email_templates['body_templ'].format( name=name, - log_root=misc.get_http_log_path(archive_dir, ''), + log_root=misc.get_http_log_path(archive_dir), fail_count=len(failed), hung_count=len(hung), pass_count=len(passed), diff --git a/teuthology/test/test_misc.py b/teuthology/test/test_misc.py index 5e38c3fb01c55..1e71842fb9307 100644 --- a/teuthology/test/test_misc.py +++ b/teuthology/test/test_misc.py @@ -32,6 +32,7 @@ def test_get_clients_simple(): def test_get_http_log_path(): + # Fake configuration archive_server = "http://example.com/server_root" config.archive_server = archive_server archive_dir = "/var/www/archives" @@ -42,3 +43,14 @@ def test_get_http_log_path(): job_id = '12345' path = misc.get_http_log_path(archive_dir, job_id) assert_equal(path, "http://example.com/server_root/archives/12345/") + + # Inktank configuration + archive_server = "http://qa-proxy.ceph.com/teuthology/" + config.archive_server = archive_server + archive_dir = "/var/lib/teuthworker/archive/teuthology-2013-09-12_11:49:50-ceph-deploy-master-testing-basic-vps" + job_id = 31087 + path = misc.get_http_log_path(archive_dir, job_id) + assert_equal(path, "http://qa-proxy.ceph.com/teuthology/teuthology-2013-09-12_11:49:50-ceph-deploy-master-testing-basic-vps/31087/") + + path = misc.get_http_log_path(archive_dir) + assert_equal(path, "http://qa-proxy.ceph.com/teuthology/teuthology-2013-09-12_11:49:50-ceph-deploy-master-testing-basic-vps/") -- 2.39.5