summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/agent/unittest/env/test_sourcemanager.py
diff options
context:
space:
mode:
authorYiting.Li <liyiting@huawei.com>2015-12-22 17:11:12 -0800
committerYiting.Li <liyiting@huawei.com>2015-12-22 17:11:12 -0800
commit8f1101df131a4d3e03b377738507d88b745831c0 (patch)
tree73f140474fcec2a77c85a453f6946957ca0742d1 /vstf/vstf/agent/unittest/env/test_sourcemanager.py
parent1a24ebbda3f95600c0e7d5ed8661317a8ff7e265 (diff)
Upload the contribution of vstf as bottleneck network framework.
End to End Performance test JIRA:BOTTLENECK-29 Change-Id: Ib2c553c8b60d6cda9e7a7b52b737c9139f706ebd Signed-off-by: Yiting.Li <liyiting@huawei.com>
Diffstat (limited to 'vstf/vstf/agent/unittest/env/test_sourcemanager.py')
-rwxr-xr-xvstf/vstf/agent/unittest/env/test_sourcemanager.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/vstf/vstf/agent/unittest/env/test_sourcemanager.py b/vstf/vstf/agent/unittest/env/test_sourcemanager.py
new file mode 100755
index 00000000..fda567d8
--- /dev/null
+++ b/vstf/vstf/agent/unittest/env/test_sourcemanager.py
@@ -0,0 +1,53 @@
+"""
+Created on 2015-10-9
+
+@author: y00228926
+"""
+import unittest
+import shutil
+import time
+import os
+
+from vstf.agent.env.basic.source_manager import SourceCodeManager
+from vstf.agent.unittest.env import model
+
+
+class TestSourceManager(model.Test):
+ def setUp(self):
+ super(TestSourceManager, self).setUp()
+ self.sm = SourceCodeManager()
+ self.dest_path = '/tmp/test_source_manager'
+ os.mkdir(self.dest_path)
+
+ def tearDown(self):
+ shutil.rmtree(self.dest_path, ignore_errors = True)
+
+ def _time(self,func):
+ def _deco(*args):
+ start_time = time.time()
+ func(*args)
+ end_time = time.time()
+ return end_time - start_time
+ return _deco
+
+ def test_download_source_code(self):
+ for key, item in self.source_repo.items():
+ print self.source_repo
+ url = item['url']
+ target = os.path.join(self.dest_path, key)
+ install = item['install']
+ if install:
+ self.sm._git_pull(url, target)
+ self.assertTrue(os.path.isdir(target))
+ my_download = self._time(self.sm._git_pull)
+ t = my_download(url, target)
+ self.assertTrue(t < 1.0)
+ else:
+ self.assertFalse(os.path.isdir(target))
+
+
+if __name__ == "__main__":
+ import logging
+ logging.basicConfig(level = logging.INFO)
+ LOG = logging.getLogger(__name__)
+ unittest.main() \ No newline at end of file