Permalink
Browse files

new test for chunked rpm uploads

  • Loading branch information...
1 parent 2ea601f commit 3225aa6d8a7861c5fb133eb66797ff286f8e3d26 @heroldus heroldus committed Aug 27, 2012
Showing with 23 additions and 1 deletion.
  1. +1 −1 src/config_rpm_maker/__init__.py
  2. +21 −0 test/configRpmMaker.py
  3. +1 −0 yadt-config-rpm-maker.yaml
@@ -222,7 +222,7 @@ def _prepare_work_dir(self):
os.makedirs(path)
def _get_chunk_size(self, rpms):
- chunk_size = int(config.get('rpm_upload_cmd_chunk_size', 0))
+ chunk_size = int(config.get('rpm_upload_chunk_size', 0))
if chunk_size < 0:
raise Exception("Config param 'rpm_upload_cmd_chunk_size' needs to be greater or equal 0")
View
@@ -60,6 +60,27 @@ def test_build_hosts(self):
for host in hosts_to_check:
self.assertRpm(host, rpms, requires=hosts_to_check[host].get('requires', None), provides=hosts_to_check[host].get('provides', None), files=hosts_to_check[host].get('files', None))
+ def test_chunked_uploads(self):
+ old_config = config.get('rpm_upload_cmd')
+ target_file = os.path.abspath(os.path.join(config.get('temp_dir'), 'upload.txt'))
+ if os.path.exists(target_file):
+ os.remove(target_file)
+ cmd_file = os.path.abspath(os.path.join(config.get('temp_dir'), 'upload.sh'))
+ with open(cmd_file, 'w') as f:
+ f.write('#!/bin/bash\ndest=$1 ; shift ; echo "${#@} $@" >> "$dest"')
+
+ os.chmod(cmd_file, 0755)
+ cmd = '%s %s' % (cmd_file, target_file)
+ config.config['rpm_upload_cmd'] = cmd
+ try:
+ ConfigRpmMaker(None, None)._upload_rpms(['a' for x in range(25)])
+ finally:
+ config.config['rpm_upload_cmd'] = old_config
+
+ self.assertTrue(os.path.exists(target_file))
+ with open(target_file) as f:
+ self.assertEqual(f.read(), '10 a a a a a a a a a a\n10 a a a a a a a a a a\n5 a a a a a\n')
+
def _given_config_rpm_maker(self, keep_work_dir = False):
self._cleanup_temp_dir()
self.create_svn_repo()
@@ -7,6 +7,7 @@ custom_dns_searchlist : []
allow_unknown_hosts : true
config_viewer_dir : 'target/tmp/configviewer'
rpm_upload_cmd : '/bin/true'
+rpm_upload_chunk_size : 10
log_level : 'DEBUG'
thread_count : 4
error_log_dir : 'target/tmp/configviewer/errors'

0 comments on commit 3225aa6

Please sign in to comment.