Skip to content

Commit

Permalink
Merge 93952bf into fdc647b
Browse files Browse the repository at this point in the history
  • Loading branch information
arpras committed Oct 15, 2015
2 parents fdc647b + 93952bf commit 8a458e5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 17 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ before_install:
- cat /dev/zero | ssh-keygen -q -N ""
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# install dependencies
install: "python setup.py install"
install:
- "python setup.py install"
- "pip install coverage"
- "pip install coveralls"
# run tests
script:
- python setup.py test
- zopkio examples/server_client/server_client.py --nopassword
- python setup.py test
- coverage run --source=zopkio setup.py test
after_success:
- coveralls
7 changes: 5 additions & 2 deletions examples/zookeeper/deploy_zookeepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def setup_suite():
print "Starting zookeeper"
print "Starting zookeeper quorum"
global zookeper_deployer
env_dict = {}

Expand All @@ -43,6 +43,7 @@ def setup_suite():
runtime.set_deployer("zookeeper", zookeper_deployer)

# Deploy Zookeeper1
print "Deploy Zookeeper1"
zookeper_deployer.install("zookeeper1",
{"hostname": "localhost",
"install_path": runtime.get_active_config('zookeeper1_install_path'),
Expand All @@ -52,6 +53,7 @@ def setup_suite():
zookeper_deployer.start("zookeeper1",configs={"sync": True})

# Deploy Zookeeper2
print "Deploy Zookeeper2"
zookeper_deployer.install("zookeeper2",
{"hostname": "localhost",
"install_path": runtime.get_active_config('zookeeper2_install_path'),
Expand All @@ -61,6 +63,7 @@ def setup_suite():
zookeper_deployer.start("zookeeper2",configs={"sync": True})

# Deploy Zookeeper3
print "Deploy Zookeeper3"
zookeper_deployer.install("zookeeper3",
{"hostname": "localhost",
"install_path": runtime.get_active_config('zookeeper3_install_path'),
Expand All @@ -75,4 +78,4 @@ def teardown_suite():
zookeper_deployer.undeploy("zookeeper1")
zookeper_deployer.undeploy("zookeeper2")
zookeper_deployer.undeploy("zookeeper3")
print "zookeeper terminated"
print "zookeepers terminated"
2 changes: 1 addition & 1 deletion test/test_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_get_logs(self):
with open(os.path.join(install_path, 'test.foo'), 'w') as f:
f.write('this is the test foo')
minimial_deployer.processes['unique_id'] = Process('unique_id', 'service_name', 'localhost', install_path)
minimial_deployer.get_logs('unique_id', [os.path.join(install_path, 'test.out')], output_path)
minimial_deployer.get_logs('unique_id', [os.path.join(install_path, 'test.out')], output_path, '')
assert os.path.exists(os.path.join(output_path, "unique_id-test.out"))
shutil.rmtree(output_path)
if not os.path.exists(output_path):
Expand Down
6 changes: 3 additions & 3 deletions test/test_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_copy_log_machine_logs_speced_per_id(self):
localhost_log_file = os.path.join(localhost_logs_dir, "unittest.log")
ztestsuite = SampleTestSuite(Mock_Deployer())
ztestsuite.machine_logs = lambda unique_id: [localhost_log_file]
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file)
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file, False)
finally:
shutil.rmtree( localhost_logs_dir)

Expand Down Expand Up @@ -235,7 +235,7 @@ def test_copy_log_process_logs_speced_per_id(self):
localhost_log_file = os.path.join(localhost_logs_dir, "unittest.log")
ztestsuite = SampleTestSuite(Mock_Deployer())
ztestsuite.process_logs = lambda unique_id: [localhost_log_file]
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file)
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file, False)
finally:
shutil.rmtree( localhost_logs_dir)

Expand Down Expand Up @@ -269,7 +269,7 @@ def test_copy_log_naarad_logs_speced_per_id(self):
localhost_log_file = os.path.join(localhost_logs_dir, "unittest.log")
ztestsuite = SampleTestSuite(Mock_Deployer())
ztestsuite.naarad_logs = lambda unique_id: [localhost_log_file]
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file)
self.__test_copy_log_speced_per_id(ztestsuite, localhost_log_file, False)
finally:
#cleanup
shutil.rmtree( localhost_logs_dir)
Expand Down
2 changes: 1 addition & 1 deletion test/test_zopkio.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_zopkio_launch(self):
args.testfile = "./examples/server_client/server_client.py"
succeeded, failed = self._run_zopkio(args)
self.assertTrue( succeeded >= 4)
self.assertTrue( failed >= 16)
self.assertTrue( failed >= 12)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion zopkio/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
CONFIG_SEPARATOR = '='
MACHINE_SEPARATOR = '='

FILTER_NAME_ALLOW_ALL=''
FILTER_NAME_ALLOW_NONE='^$'
6 changes: 3 additions & 3 deletions zopkio/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ def hangup(self, unique_id, configs=None):
"""
self._send_signal(unique_id, signal.SIGHUP, configs)

def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_ALL):
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
"""deprecated name for fetch_logs"""
self.fetch_logs(unique_id, logs, directory, pattern)

def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_ALL):
def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
""" Copies logs from the remote host that the process is running on to the provided directory
:Parameter unique_id the unique_id of the process in question
Expand Down Expand Up @@ -266,7 +266,7 @@ def fetch_logs_from_host(hostname, install_path, prefix, logs, directory, patter
logger.error("Log file " + f + " does not exist on " + hostname)
pass
else:
copy_dir(ftp, f, directory, prefix, pattern)
copy_dir(ftp, f, directory, prefix)
if install_path is not None:
copy_dir(ftp, install_path, directory, prefix, pattern)

Expand Down
4 changes: 2 additions & 2 deletions zopkio/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def assign_log_methods( method_name):
assign_log_methods( method_name )

if not hasattr( self.dynamic_config_module, "log_patterns"):
setattr( self.dynamic_config_module, "log_patterns", wrap( lambda unique_id: constants.FILTER_NAME_ALLOW_ALL ))
setattr( self.dynamic_config_module, "log_patterns", wrap( lambda unique_id: constants.FILTER_NAME_ALLOW_NONE ))
else:
self.dynamic_config_module.log_patterns = wrap( self.dynamic_config_module.log_patterns)
self._output_dir = self.master_config.mapping.get("OUTPUT_DIRECTORY") or self.dynamic_config_module.OUTPUT_DIRECTORY
Expand Down Expand Up @@ -257,7 +257,7 @@ def _copy_logs(self):
logs = self.dynamic_config_module.process_logs( process.servicename) or []
logs += self.dynamic_config_module.machine_logs( process.unique_id)
logs += self.dynamic_config_module.naarad_logs( process.unique_id)
pattern = self.dynamic_config_module.log_patterns(process.unique_id) or constants.FILTER_NAME_ALLOW_ALL
pattern = self.dynamic_config_module.log_patterns(process.unique_id) or constants.FILTER_NAME_ALLOW_NONE
#now copy logs filtered on given pattern to local machine:
deployer.fetch_logs(process.unique_id, logs, self._logs_dir, pattern)

Expand Down
2 changes: 1 addition & 1 deletion zopkio/ztests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def log_patterns(self, process_unique_id):
:param process_unique_id: the unique id for the process
:return: filter that matches any file name
"""
return constants.FILTER_NAME_ALLOW_ALL
return constants.FILTER_NAME_ALLOW_NONE


def should_fetch_logs(self):
Expand Down

0 comments on commit 8a458e5

Please sign in to comment.