def test_start_and_stop_one_duplicate(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) actions.start_and_wait(service_resolver, context, ["TEST_ONE"], False, False, False, None, port=None, seconds_to_wait=90, append_args=None) self.assertIsNotNone(context.get_service("TEST_ONE").status()) result = actions.start_one(context, "TEST_ONE", False, True, False, None, port=None) self.assertFalse(result) context.kill("TEST_ONE", True) self.assertEqual(context.get_service("TEST_ONE").status(), [])
def test_successful_play_from_jar_without_waiting_with_append_args(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything(True) self.startFakeNexus() servicetostart = ["PLAY_NEXUS_END_TO_END_TEST"] appendArgs = {"PLAY_NEXUS_END_TO_END_TEST": ["-DFoo=Bar"]} fatJar = True release = False proxy = None port = None seconds_to_wait = None actions.start_and_wait(service_resolver, context, servicetostart, False, fatJar, release, proxy, port, seconds_to_wait, appendArgs) service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST") self.waitForCondition( lambda: len(SmProcess.processes_matching(service.pattern)), 1) processes = SmProcess.processes_matching(service.pattern) self.assertTrue("-DFoo=Bar" in processes[0].args)
def test_wait_on_assets_server(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything() context.kill("FAKE_NEXUS") self.assertEqual(context.get_service("FAKE_NEXUS").status(), []) time.sleep(2) # start fake nexus self.assertEqual(context.get_service("FAKE_NEXUS").status(), []) response1 = actions.start_one(context, "FAKE_NEXUS", False, True, False, None, port=None) self.assertTrue(response1) self.assertIsNotNone(context.get_service("FAKE_NEXUS").status()) time.sleep(5) port = None seconds_to_wait = 5 append_args = None actions.start_and_wait(service_resolver, context, ["PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND"], False, True, False, None, port, seconds_to_wait, append_args) self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status()) context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND") context.kill("FAKE_NEXUS") time.sleep(15) self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), []) self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
def test_wait_on_assets_server(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything(True) self.startFakeArtifactory() port = None seconds_to_wait = 5 append_args = None actions.start_and_wait( service_resolver, context, ["PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND"], False, True, False, None, port, seconds_to_wait, append_args, ) self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status()) context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", True) self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), [])
def test_successful_play_default_run_from_jar_without_waiting(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything(True) self.startFakeNexus() source = False fatJar = True release = False proxy = None port = None seconds_to_wait = None append_args = None try: servicetostart = ["PLAY_NEXUS_END_TO_END_DEFAULT_JAR_TEST"] actions.start_and_wait( service_resolver, context, servicetostart, source, fatJar, release, proxy, port, seconds_to_wait, append_args, ) finally: context.kill_everything(True)
def test_successful_play_from_jar_without_waiting(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything() time.sleep(5) response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, port=None) self.assertTrue(response1) self.assertIsNotNone(context.get_service("FAKE_NEXUS").status()) time.sleep(5) fatJar = True release = False proxy = None port = None seconds_to_wait = None append_args = None try: servicetostart = ["PLAY_NEXUS_END_TO_END_TEST"] actions.start_and_wait(service_resolver, context, servicetostart, fatJar, release, proxy, port, seconds_to_wait, append_args) finally: context.kill_everything()
def test_successful_play_from_jar_without_waiting_with_append_args(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything() time.sleep(5) response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, None, None) self.assertTrue(response1) self.assertIsNotNone(context.get_service("FAKE_NEXUS").status()) time.sleep(5) servicetostart = ["PLAY_NEXUS_END_TO_END_TEST"] appendArgs = {"PLAY_NEXUS_END_TO_END_TEST": ["-DFoo=Bar"]} fatJar = True release = False proxy = None port = None seconds_to_wait = None try: actions.start_and_wait(service_resolver, context, servicetostart, fatJar, release, proxy, port, seconds_to_wait, appendArgs) time.sleep(5) service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST") processes = SmProcess.processes_matching(service.pattern) self.assertEqual(len(processes), 1) self.assertTrue("-DFoo=Bar" in processes[0].args) finally: context.kill_everything()
def test_dropwizard_from_jar(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) # start fake nexus actions.start_one(context, "FAKE_NEXUS", True, False, None, port=None) self.assertIsNotNone(context.get_service("FAKE_NEXUS").status()) time.sleep(5) servicetostart = "DROPWIZARD_NEXUS_END_TO_END_TEST" actions.start_and_wait(service_resolver, context, [servicetostart], True, False, None, port=None, seconds_to_wait=90, append_args=None) self.assertIsNotNone(context.get_service(servicetostart).status()) context.kill(servicetostart) context.kill("FAKE_NEXUS") time.sleep(5) self.assertEqual(context.get_service(servicetostart).status(), []) self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
def test_failing_play_from_jar(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything(True) self.startFakeNexus() try: servicetostart = ["BROKEN_PLAY_PROJECT"] actions.start_and_wait(service_resolver, context, servicetostart, source=False, fatjar=True, release=False, proxy=None, port=None, seconds_to_wait=2, append_args=None) self.fail("Did not expect the project to startup.") except ServiceManagerException as sme: self.assertEqual( "Timed out starting service(s): BROKEN_PLAY_PROJECT", sme.message) finally: context.kill_everything(True)
def test_config(self): application = SmApplication(self.config_dir_override, None) service_resolver = ServiceResolver(application) nexus_wildcard = service_resolver.resolve_services("PLAY_NEXU*TEST") self.assertTrue("PLAY_NEXUS_END_TO_END_TEST" in nexus_wildcard) self.assertEqual(5, len(nexus_wildcard)) all_services = service_resolver.resolve_services("*") self.assertTrue("TEST_ONE" in all_services) self.assertTrue("TEST_TWO" in all_services) self.assertTrue("TEST_THREE" in all_services) self.assertTrue("TEST_FOUR" in all_services) self.assertTrue("TEST_TEMPLATE" in all_services) self.assertTrue("DROPWIZARD_NEXUS_END_TO_END_TEST" in all_services) self.assertTrue("PLAY_NEXUS_END_TO_END_TEST" in all_services) self.assertTrue("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND" in all_services) self.assertEqual(16, len(all_services)) test_profile = service_resolver.resolve_services("TEST") self.assertTrue("TEST_ONE" in test_profile) self.assertTrue("TEST_TWO" in test_profile) self.assertTrue("TEST_THREE" in test_profile) self.assertTrue("TEST_TEMPLATE" in test_profile) self.assertEqual(5, len(test_profile)) tests_without_one = service_resolver.resolve_services_from_array( ["TEST", "-TEST_ONE"]) self.assertFalse("TEST_ONE" in tests_without_one) self.assertTrue("TEST_TWO" in tests_without_one) self.assertTrue("TEST_THREE" in tests_without_one) self.assertTrue("TEST_FOUR" in tests_without_one) self.assertTrue("TEST_TEMPLATE" in tests_without_one) self.assertEqual(4, len(tests_without_one)) tests_without_one = service_resolver.resolve_services_from_array( ["TEST_WILD_CARD_NEGATED_PROFILE"]) self.assertTrue("TEST_ONE" in tests_without_one) self.assertFalse("TEST_TWO" in tests_without_one) self.assertTrue("TEST_THREE" in tests_without_one) self.assertTrue("TEST_FOUR" in tests_without_one) self.assertTrue("TEST_TEMPLATE" in tests_without_one) self.assertEqual(4, len(tests_without_one)) nothing = service_resolver.resolve_services_from_array(["*", "-*"]) self.assertEqual(0, len(nothing)) test_template = service_resolver.resolve_services( "TEST_WILD_CARD_PROFILE") self.assertTrue("TEST_TEMPLATE" in test_template) self.assertEqual(1, len(test_template))
def start_service_and_wait(self, context, servicetostart): sm_application = SmApplication(self.config_dir_override) service_resolver = ServiceResolver(sm_application) actions.start_and_wait(service_resolver, context, [servicetostart], source=False, fatjar=True, release=False, proxy=None, port=None, seconds_to_wait=5, append_args=None)
def test_config(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") application = SmApplication(config_dir_override, None) service_resolver = ServiceResolver(application) nexus_wildcard = service_resolver.resolve_services("PLAY_NEXU*TEST") self.assertTrue("PLAY_NEXUS_END_TO_END_TEST" in nexus_wildcard) self.assertTrue("PLAY_NEXUS_END_TO_END_DEFAULT_SOURCE_TEST" in nexus_wildcard) self.assertTrue("PLAY_NEXUS_END_TO_END_DEFAULT_JAR_TEST" in nexus_wildcard) self.assertEqual(5, len(nexus_wildcard)) all_services = service_resolver.resolve_services("*") self.assertTrue("TEST_ONE" in all_services) self.assertTrue("TEST_TWO" in all_services) self.assertTrue("TEST_THREE" in all_services) self.assertTrue("TEST_TEMPLATE" in all_services) self.assertTrue("DROPWIZARD_NEXUS_END_TO_END_TEST" in all_services) self.assertTrue("PLAY_NEXUS_END_TO_END_TEST" in all_services) self.assertTrue("PLAY_NEXUS_END_TO_END_DEFAULT_SOURCE_TEST" in all_services) self.assertTrue("PLAY_NEXUS_END_TO_END_DEFAULT_JAR_TEST" in all_services) self.assertTrue("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND" in all_services) self.assertEqual(15, len(all_services)) test_profile = service_resolver.resolve_services("TEST") self.assertTrue("TEST_ONE" in test_profile) self.assertTrue("TEST_TWO" in test_profile) self.assertTrue("TEST_THREE" in test_profile) self.assertTrue("TEST_TEMPLATE" in test_profile) self.assertEqual(4, len(test_profile)) tests_without_one = service_resolver.resolve_services_from_array(["TEST", "-TEST_ONE"]) self.assertFalse("TEST_ONE" in tests_without_one) self.assertTrue("TEST_TWO" in tests_without_one) self.assertTrue("TEST_THREE" in tests_without_one) self.assertTrue("TEST_TEMPLATE" in tests_without_one) self.assertEqual(3, len(tests_without_one)) tests_without_one = service_resolver.resolve_services_from_array(["TEST_WILD_CARD_NEGATED_PROFILE"]) self.assertTrue("TEST_ONE" in tests_without_one) self.assertFalse("TEST_TWO" in tests_without_one) self.assertTrue("TEST_THREE" in tests_without_one) self.assertTrue("TEST_TEMPLATE" in tests_without_one) self.assertEqual(3, len(tests_without_one)) nothing = service_resolver.resolve_services_from_array(["*", "-*"]) self.assertEqual(0, len(nothing)) test_template = service_resolver.resolve_services("TEST_WILD_CARD_PROFILE") self.assertTrue("TEST_TEMPLATE" in test_template) self.assertEqual(1, len(test_template))
def test_play_from_source_default(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) servicetostart = "PLAY_NEXUS_END_TO_END_TEST" port = None secondsToWait = 90 append_args = None actions.start_and_wait(service_resolver, context, [servicetostart], False, False, False, None, port, secondsToWait, append_args) self.assertIsNotNone(context.get_service(servicetostart).status()) context.kill(servicetostart) self.assertEqual(context.get_service(servicetostart).status(), [])
def test_play_from_default_run_from_source(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) servicetostart = "PLAY_NEXUS_END_TO_END_DEFAULT_SOURCE_TEST" port = None secondsToWait = 90 append_args = None actions.start_and_wait(service_resolver, context, [servicetostart], False, False, False, None, port, secondsToWait, append_args) self.assertIsNotNone(context.get_service(servicetostart).status()) context.kill(servicetostart, True) self.assertEqual(context.get_service(servicetostart).status(), [])
def test_dropwizard_from_source(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) servicetostart = "DROPWIZARD_NEXUS_END_TO_END_TEST" actions.start_and_wait(service_resolver, context, [servicetostart], False, False, None, port=None, seconds_to_wait=90) self.assertIsNotNone(context.get_service(servicetostart).status()) context.kill(servicetostart) self.assertEqual(context.get_service(servicetostart).status(), [])
def test_dropwizard_from_source(self): sm_application = SmApplication(self.config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) servicetostart = "DROPWIZARD_NEXUS_END_TO_END_TEST" actions.start_and_wait(service_resolver, context, [servicetostart], False, False, False, None, port=None, seconds_to_wait=90, append_args=None) self.assertIsNotNone(context.get_service(servicetostart).status()) context.kill(servicetostart, True) self.assertEqual(context.get_service(servicetostart).status(), [])
def test_failing_play_from_jar(self): config_dir_override = os.path.join(os.path.dirname(__file__), "conf") sm_application = SmApplication(config_dir_override) context = SmContext(sm_application, None, False, False) service_resolver = ServiceResolver(sm_application) context.kill_everything() time.sleep(5) response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, port=None) self.assertTrue(response1) self.assertIsNotNone(context.get_service("FAKE_NEXUS").status()) time.sleep(5) try: servicetostart = ["BROKEN_PLAY_PROJECT"] actions.start_and_wait(service_resolver, context, servicetostart, fatjar=True, release=False, proxy=None, port=None, seconds_to_wait=2, append_args=None) self.fail("Did not expect the project to startup.") except ServiceManagerException as sme: self.assertEqual( "Timed out starting service(s): BROKEN_PLAY_PROJECT", sme.message) finally: context.kill_everything()