Skip to content

Commit

Permalink
Make integration tests use a sysname, and env epuh persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
oldpatricka committed Apr 12, 2013
1 parent 97717e4 commit 0d16b32
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion epu/dashiproc/highavailability.py
Expand Up @@ -80,7 +80,7 @@ def __init__(self, *args, **kwargs):
self.topic = kwargs.get('service_name') or self.CFG.highavailability.get('service_name') or DEFAULT_TOPIC

self.amqp_uri = kwargs.get('amqp_uri') or None
self.dashi = bootstrap.dashi_connect(self.topic, self.CFG, self.amqp_uri)
self.dashi = bootstrap.dashi_connect(self.topic, self.CFG, self.amqp_uri, sysname=kwargs.get('sysname'))

process_dispatchers = (kwargs.get('process_dispatchers') or
self.CFG.highavailability.processdispatchers)
Expand Down
3 changes: 1 addition & 2 deletions epu/dashiproc/processdispatcher.py
Expand Up @@ -20,8 +20,7 @@ class ProcessDispatcherService(object):
"""

def __init__(self, amqp_uri=None, topic="process_dispatcher", registry=None,
store=None, epum_client=None, notifier=None, definition_id=None, domain_config=None,
sysname=None):
store=None, epum_client=None, notifier=None, definition_id=None, domain_config=None, sysname=None):

configs = ["service", "processdispatcher"]
config_files = get_config_paths(configs)
Expand Down
25 changes: 17 additions & 8 deletions epu/highavailability/test/test_highavailability_service.py
Expand Up @@ -149,11 +149,16 @@ def _assert_n_processes(self, n, timeout=None, only_pd=None):
processes = None
for i in range(0, timeout):
processes = self.haservice.core.managed_upids
print "Procs: %s" % processes
all_procs = self.haservice.control.get_all_processes()

msg = "Managed procs: "
for upid in processes:
proc = self._get_proc_from_all_pds(upid)
msg += "%s is %s," % (upid, proc['state'])
print msg

if n == 0 and len(processes) == n:
# Check to make sure nothing running, or at least all marked terminated
all_procs = self.haservice.control.get_all_processes()
print all_procs
proc_list = []
for pd_name, procs in all_procs.iteritems():
proc_list += procs
Expand Down Expand Up @@ -200,13 +205,15 @@ def setUp(self):
if not os.environ.get("INT"):
raise SkipTest("Skipping Slow integration test")
self.exchange = "hatestexchange-%s" % str(uuid.uuid4())
self.sysname = "test-%s" % str(uuid.uuid4())

parsed_deployment = yaml.load(deployment)
self.pd_names = parsed_deployment['process-dispatchers'].keys()
policy_params = {'preserve_n': 0}
executable = {'exec': 'sleep', 'argv': ['1000']}

self.setup_harness(exchange=self.exchange)
print "ST: sysname %s" % self.sysname
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=deployment)
Expand All @@ -215,13 +222,13 @@ def setUp(self):

self.process_definition_id = uuid.uuid4().hex
for pd_name in self.pd_names:
pd_client = ProcessDispatcherClient(self.dashi, pd_name)
pd_client = ProcessDispatcherClient(self.dashi, pd_name,)
pd_client.create_definition(self.process_definition_id, None,
executable, None, None)

self.haservice = HighAvailabilityService(policy_parameters=policy_params,
process_dispatchers=self.pd_names, exchange=self.exchange,
process_definition_id=self.process_definition_id)
process_definition_id=self.process_definition_id, sysname=self.sysname)
self.haservice_thread = tevent.spawn(self.haservice.start)

self.dashi = self.haservice.dashi
Expand Down Expand Up @@ -338,6 +345,7 @@ def setUp(self):
if not os.environ.get("INT"):
raise SkipTest("Skipping Slow integration test")
self.exchange = "hatestexchange-%s" % str(uuid.uuid4())
self.sysname = "test-%s" % str(uuid.uuid4())

parsed_deployment = yaml.load(deployment_one_pd_two_eea)
self.pd_names = parsed_deployment['process-dispatchers'].keys()
Expand All @@ -348,7 +356,7 @@ def setUp(self):
policy_params = {'preserve_n': 0}
executable = {'exec': 'sleep', 'argv': ['1000']}

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=deployment_one_pd_two_eea)
Expand All @@ -362,7 +370,8 @@ def setUp(self):

self.haservice = HighAvailabilityService(policy_parameters=policy_params,
process_dispatchers=self.pd_names, exchange=self.exchange,
process_definition_id=self.process_definition_id)
process_definition_id=self.process_definition_id,
sysname=self.sysname)
self.haservice_thread = tevent.spawn(self.haservice.start)

self.dashi = self.haservice.dashi
Expand Down
Expand Up @@ -46,7 +46,6 @@ def setUp(self):
self.sysname = "test-sysname%s" % uuid.uuid4().hex

self.start_pd()
self.sysname = self.pd.dashi.sysname
self.client = ProcessDispatcherClient(self.pd.dashi, self.pd_name)

def waiter():
Expand Down
3 changes: 2 additions & 1 deletion epu/provisioner/test/test_provisioner_service_integration.py
Expand Up @@ -48,11 +48,12 @@ def setUp(self):
raise SkipTest("Slow integration test")

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

deployment = fake_libcloud_deployment % default_user

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=deployment)
Expand Down
12 changes: 8 additions & 4 deletions epu/test/test_integration.py
Expand Up @@ -260,13 +260,14 @@ def setUp(self):
'worker_dt': self.worker_dt, 'iaas_site': self.iaas_site}

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

# Set up fake libcloud and start deployment
self.site_name = "ec2-fake"
self.fake_site, self.libcloud = self.make_fake_libcloud_site(self.site_name)

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=self.deployment)
Expand Down Expand Up @@ -384,13 +385,14 @@ def setUp(self):
epum_replica_count=self.replica_count)

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

# Set up fake libcloud and start deployment
self.site_name = "ec2-fake"
self.fake_site, self.libcloud = self.make_fake_libcloud_site(self.site_name)

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=self.deployment)
Expand Down Expand Up @@ -559,13 +561,14 @@ def setUp(self):
pd_replica_count=self.replica_count)

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

# Set up fake libcloud and start deployment
self.site_name = "ec2-fake"
self.fake_site, self.libcloud = self.make_fake_libcloud_site(self.site_name)

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=self.deployment)
Expand Down Expand Up @@ -640,6 +643,7 @@ def setUp(self):
"iaas_timeout": 0.0001}

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

if (os.environ.get("LIBCLOUD_DRIVER") and os.environ.get("IAAS_HOST")
Expand All @@ -661,7 +665,7 @@ def setUp(self):
self.site, self.libcloud = self.make_fake_libcloud_site(self.site_name)
self.credentials = fake_credentials

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=self.deployment)
Expand Down
5 changes: 3 additions & 2 deletions epu/test/test_integration_creds.py
Expand Up @@ -71,13 +71,14 @@


def setUpModule():
epuh_persistence = "/tmp/SupD/epuharness"
epuh_persistence = os.environ.get('EPUHARNESS_PERSISTENCE_DIR', '/tmp/SupD/epuharness')
if os.path.exists(epuh_persistence):
raise SkipTest("EPUHarness running. Can't run this test")

global g_epuharness
exchange = "testexchange-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange)
sysname = "testsysname-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange, sysname=sysname)
g_epuharness.start(deployment_str=g_deployment)


Expand Down
7 changes: 4 additions & 3 deletions epu/test/test_integration_domain.py
Expand Up @@ -76,13 +76,14 @@ def _make_dt(site_name):


def setUpModule():
epuh_persistence = "/tmp/SupD/epuharness"
epuh_persistence = os.environ.get('EPUHARNESS_PERSISTENCE_DIR', '/tmp/SupD/epuharness')
if os.path.exists(epuh_persistence):
raise SkipTest("EPUHarness running. Can't run this test")

global g_epuharness
exchange = "testexchange-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange)
sysname = "testsysname-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange, sysname=sysname)
g_epuharness.start(deployment_str=g_deployment)


Expand Down Expand Up @@ -553,7 +554,7 @@ def many_domain_vary_remove_test(self):
time.sleep(0.5)

for i in range(0, 64):
# every other time add a VM then remove a VM
# every other time add a Domain then remove a Domain

if i % 2 == 0:
print "add a VM"
Expand Down
5 changes: 3 additions & 2 deletions epu/test/test_integration_dtrs.py
Expand Up @@ -77,13 +77,14 @@


def setUpModule():
epuh_persistence = "/tmp/SupD/epuharness"
epuh_persistence = os.environ.get('EPUHARNESS_PERSISTENCE_DIR', '/tmp/SupD/epuharness')
if os.path.exists(epuh_persistence):
raise SkipTest("EPUHarness running. Can't run this test")

global g_epuharness
exchange = "testexchange-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange)
sysname = "testsysname-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange, sysname=sysname)
g_epuharness.start(deployment_str=g_deployment)


Expand Down
5 changes: 3 additions & 2 deletions epu/test/test_integration_site.py
Expand Up @@ -76,13 +76,14 @@


def setUpModule():
epuh_persistence = "/tmp/SupD/epuharness"
epuh_persistence = os.environ.get('EPUHARNESS_PERSISTENCE_DIR', '/tmp/SupD/epuharness')
if os.path.exists(epuh_persistence):
raise SkipTest("EPUHarness running. Can't run this test")

global g_epuharness
exchange = "testexchange-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange)
sysname = "testsysname-%s" % str(uuid.uuid4())
g_epuharness = EPUHarness(exchange=exchange, sysname=sysname)
g_epuharness.start(deployment_str=g_deployment)


Expand Down
5 changes: 3 additions & 2 deletions epu/test/test_phantom_integration.py
Expand Up @@ -82,14 +82,15 @@ def setUp(self):
raise SkipTest("sqlalchemy not available.")

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

self.epuh_persistence = "/tmp/SupD/epuharness"
self.epuh_persistence = os.environ.get('EPUHARNESS_PERSISTENCE_DIR', '/tmp/SupD/epuharness')
if os.path.exists(self.epuh_persistence):
raise SkipTest("EPUHarness running. Can't run this test")

# Set up fake libcloud and start deployment
self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=deployment)
Expand Down
3 changes: 2 additions & 1 deletion epu/test/test_zk_leaders_epum.py
Expand Up @@ -122,10 +122,11 @@ def setUp(self):
epum_replica_count=self.epum_replica_count, prov_replica_count=self.prov_replica_count)

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

# Set up fake libcloud and start deployment
self.setup_harness()
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.site_name = "ec2-fake"
Expand Down
3 changes: 2 additions & 1 deletion epu/test/test_zk_leaders_provisioner.py
Expand Up @@ -121,13 +121,14 @@ def setUp(self):
epum_replica_count=self.epum_replica_count, prov_replica_count=self.prov_replica_count)

self.exchange = "testexchange-%s" % str(uuid.uuid4())
self.sysname = "testsysname-%s" % str(uuid.uuid4())
self.user = default_user

# Set up fake libcloud and start deployment
self.site_name = "ec2-fake"
self.fake_site, self.libcloud = self.make_fake_libcloud_site("ec2-fake")

self.setup_harness(exchange=self.exchange)
self.setup_harness(exchange=self.exchange, sysname=self.sysname)
self.addCleanup(self.cleanup_harness)

self.epuharness.start(deployment_str=self.deployment)
Expand Down

0 comments on commit 0d16b32

Please sign in to comment.