Пример #1
0
    def test_nexus(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")

        # start fake nexus
        context = SmContext(SmApplication(config_dir_override), None, False,
                            False)
        response1 = actions.start_one(context,
                                      "FAKE_NEXUS",
                                      True,
                                      False,
                                      None,
                                      port=None)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        context = SmContext(SmApplication(config_dir_override), None, False,
                            False)
        servicetostart = "PLAY_NEXUS_END_TO_END_TEST"
        actions.start_one(context,
                          servicetostart,
                          True,
                          False,
                          None,
                          port=None)
        self.assertIsNotNone(context.get_service(servicetostart).status())
        context.kill(servicetostart)

        context.kill("FAKE_NEXUS")

        self.assertEqual(context.get_service(servicetostart).status(), [])
        self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
Пример #2
0
 def test_start_and_stop_one(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, False, False)
     actions.start_one(context, "TEST_ONE", False, True, False, None, port=None)
     self.assertEquals(len(context.get_service("TEST_ONE").status()), 1)
     context.kill("TEST_ONE")
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #3
0
 def test_start_and_stop_one_with_append_args(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, False, False)
     actions.start_one(context, "TEST_ONE", False, True, False, None, None, ["; echo 'Fin du sleep!!'"])
     self.assertEquals(len(context.get_service("TEST_ONE").status()), 2) # it is two in this case because the append creates a forked process
     context.kill("TEST_ONE")
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #4
0
    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(), [])
Пример #5
0
    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(), [])
Пример #6
0
 def test_start_and_stop_one(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = smcontext.SmContext(smcontext.SmApplication(config_dir_override), None, False, False)
     actions.start_one(context, "TEST_ONE", True, False, None, port=None)
     self.assertIsNotNone(context.get_service("TEST_ONE").status())
     context.kill("TEST_ONE")
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #7
0
    def test_file_server(self):
        name = "FAKE_NEXUS"
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False,
                            False)

        context.kill(name)
        self.assertEqual(context.get_service(name).status(), [])
        time.sleep(2)

        response1 = actions.start_one(context,
                                      name,
                                      True,
                                      False,
                                      None,
                                      port=None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service(name).status())
        response2 = actions.start_one(context,
                                      name,
                                      True,
                                      False,
                                      None,
                                      port=None)
        self.assertFalse(response2)
        context.kill(name)
        self.assertEqual(context.get_service(name).status(), [])
Пример #8
0
 def test_start_and_stop_one_with_append_args(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, False, False)
     actions.start_one(context, "TEST_ONE", True, False, None, None, ["; echo 'Fin du sleep!!'"])
     self.assertEquals(len(context.get_service("TEST_ONE").status()), 2) # it is two in this case because the append creates a forked process
     context.kill("TEST_ONE")
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #9
0
 def test_python_server_offline(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = smcontext.SmContext(smcontext.SmApplication(config_dir_override), None, True, False)
     actions.start_one(context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", True, False, None, port=None)
     self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status())
     context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND")
     time.sleep(5)
     self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), [])
Пример #10
0
 def test_python_server_offline(self):
     context = SmContext(SmApplication(self.config_dir_override), None, True, False)
     port = None
     append_args = None
     actions.start_one(context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", False, True, False, None, port, 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(), [])
Пример #11
0
 def test_start_and_stop_one_with_append_args(self):
     context = SmContext(SmApplication(self.config_dir_override), None,
                         False, False)
     actions.start_one(context, "TEST_FOUR", False, True, False, None, None,
                       ["2"])
     self.waitForCondition(
         (lambda: len(context.get_service("TEST_FOUR").status())), 1)
     context.kill("TEST_FOUR", True)
     self.assertEqual(context.get_service("TEST_FOUR").status(), [])
Пример #12
0
 def test_python_server_offline(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, True, False)
     port = None
     append_args = None
     actions.start_one(context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", False, True, False, None, port, append_args)
     self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status())
     context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND")
     time.sleep(5)
     self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), [])
Пример #13
0
 def test_python_server_offline(self):
     context = SmContext(SmApplication(self.config_dir_override), None, True, False)
     port = None
     append_args = None
     actions.start_one(
         context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", False, True, False, None, port, 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(), [])
Пример #14
0
    def test_assets_server(self):
        context = SmContext(SmApplication(self.config_dir_override), None, False, False)
        context.kill_everything(True)

        self.startFakeNexus()

        actions.start_one(context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", False, True, False, None, port=None)
        self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status())
        context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", wait=True)

        self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), [])
Пример #15
0
    def test_assets_server(self):
        context = SmContext(SmApplication(self.config_dir_override), None, False, False)
        context.kill_everything(True)

        self.startFakeArtifactory()

        actions.start_one(
            context, "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", False, True, False, None, port=None,
        )
        self.assertIsNotNone(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status())
        context.kill("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND", wait=True)

        self.assertEqual(context.get_service("PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND").status(), [])
Пример #16
0
    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(), [])
Пример #17
0
    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(), [])
Пример #18
0
    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()
Пример #19
0
    def test_file_server(self):
        name = "FAKE_NEXUS"
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = smcontext.SmContext(smcontext.SmApplication(config_dir_override), None, False, False)

        context.kill("FAKE_NEXUS")
        self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
        time.sleep(2)

        response1 = actions.start_one(context, name, True, False, None, port=None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service(name).status())
        response2 = actions.start_one(context, name, True, False, None, port=None)
        self.assertFalse(response2)
        context.kill(name)
        self.assertEqual(context.get_service(name).status(), [])
Пример #20
0
    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()
Пример #21
0
    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()
Пример #22
0
    def test_wait_on_assets_server(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        sm_application = smcontext.SmApplication(config_dir_override)
        context = smcontext.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", True, False, None, port=None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        actions.start_and_wait(service_resolver, context, ["PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND"], True, False, None, port=None, seconds_to_wait=5)
        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(), [])
Пример #23
0
    def test_play_with_append_args(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False, False)
        context.kill_everything()

        # Start up fake nexus first
        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)

        server = smserverlogic.SmServer(SmApplication(config_dir_override, None))
        request = dict()
        request["testId"] = "foo"
        request["services"] = [
            {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT", "appendArgs": ["-Dfoo=bar"]}
        ]
        smserverlogic.SmStartRequest(server, request, True, False).process_request()
        time.sleep(5)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)
        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)
        context.kill_everything()
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #24
0
    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()
Пример #25
0
    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()
Пример #26
0
    def test_start_and_stop_one(self):
        context = SmContext(SmApplication(self.config_dir_override), None, False, False)
        result = actions.start_one(context, "TEST_ONE", False, True, False, None, port=None)
        self.assertTrue(result)

        self.waitForCondition((lambda: len(context.get_service("TEST_ONE").status())), 1)
        context.kill("TEST_ONE", True)
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #27
0
    def test_start_and_stop_one(self):
        context = SmContext(SmApplication(self.config_dir_override), None, False, False)
        result = actions.start_one(context, "TEST_ONE", False, True, False, None, port=None)
        self.assertTrue(result)

        self.waitForCondition((lambda : len(context.get_service("TEST_ONE").status())), 1)
        context.kill("TEST_ONE", True)
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #28
0
    def test_nexus(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")

        # start fake nexus
        context = smcontext.SmContext(smcontext.SmApplication(config_dir_override), None, False, False)
        response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, port=None)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        context = smcontext.SmContext(smcontext.SmApplication(config_dir_override), None, False, False)
        servicetostart = "PLAY_NEXUS_END_TO_END_TEST"
        actions.start_one(context, servicetostart, True, False, None, port=None)
        self.assertIsNotNone(context.get_service(servicetostart).status())
        context.kill(servicetostart)

        context.kill("FAKE_NEXUS")

        self.assertEqual(context.get_service(servicetostart).status(), [])
        self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
Пример #29
0
    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(), [])
Пример #30
0
 def test_start_and_stop_one_duplicate(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, False,
                         False)
     response1 = actions.start_one(context,
                                   "TEST_ONE",
                                   True,
                                   False,
                                   None,
                                   port=None)
     self.assertTrue(response1)
     self.assertIsNotNone(context.get_service("TEST_ONE").status())
     response2 = actions.start_one(context,
                                   "TEST_ONE",
                                   True,
                                   False,
                                   None,
                                   port=None)
     self.assertFalse(response2)
     context.kill("TEST_ONE")
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #31
0
    def test_assets_server(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False,
                            False)
        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",
                                      True,
                                      False,
                                      None,
                                      port=None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        actions.start_one(context,
                          "PYTHON_SIMPLE_SERVER_ASSETS_FRONTEND",
                          True,
                          False,
                          None,
                          port=None)
        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(), [])
Пример #32
0
    def test_ensure_multiple_instances_of_a_service_can_be_started_from_server(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False, False)
        context.kill_everything()
        server = smserverlogic.SmServer(SmApplication(config_dir_override, None))

        # start fake nexus
        self.assertEqual(context.get_service("FAKE_NEXUS").status(), [])
        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)

        first_request = dict()
        first_request["testId"] = "multiple-instance-unit-test-1"
        first_request["services"] = [
            {"serviceName": "TEST_ONE", "runFrom": "SNAPSHOT"},
            {"serviceName": "DROPWIZARD_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
            {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
        ]
        request = smserverlogic.SmStartRequest(server, first_request, True, False)
        request.process_request()

        time.sleep(5)
        self.assertEqual(len(context.get_service("TEST_ONE").status()), 1)
        self.assertEqual(len(context.get_service("DROPWIZARD_NEXUS_END_TO_END_TEST").status()), 1)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)

        second_request = dict()
        second_request["testId"] = "multiple-instance-unit-test-2"
        second_request["services"] = [
            {"serviceName": "TEST_ONE", "runFrom": "SNAPSHOT"},
            {"serviceName": "DROPWIZARD_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
            {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
        ]
        smserverlogic.SmStartRequest(server, second_request, True, False).process_request()
        time.sleep(5)
        self.assertEqual(len(context.get_service("TEST_ONE").status()), 2)
        self.assertEqual(len(context.get_service("DROPWIZARD_NEXUS_END_TO_END_TEST").status()), 2)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 2)

        # stop does not currently work for extern
        # smserverlogic.SmStopRequest(SERVER, request).process_request()
        context.kill_everything()
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
        context.kill("FAKE_NEXUS")
Пример #33
0
    def test_ensure_multiple_instances_of_a_service_can_be_started_from_server(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False, False)
        context.kill_everything()
        server = smserverlogic.SmServer(SmApplication(config_dir_override, None))

        # 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)

        first_request = dict()
        first_request["testId"] = "multiple-instance-unit-test-1"
        first_request["services"] = [{"serviceName": "TEST_ONE", "runFrom": "SNAPSHOT"},
                                     {"serviceName": "DROPWIZARD_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
                                     {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"}]
        request = smserverlogic.SmStartRequest(server, first_request, True, False)
        request.process_request()

        time.sleep(5)
        self.assertEqual(len(context.get_service("TEST_ONE").status()), 1)
        self.assertEqual(len(context.get_service("DROPWIZARD_NEXUS_END_TO_END_TEST").status()), 1)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)

        second_request = dict()
        second_request["testId"] = "multiple-instance-unit-test-2"
        second_request["services"] = [{"serviceName": "TEST_ONE", "runFrom": "SNAPSHOT"},
                                      {"serviceName": "DROPWIZARD_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"},
                                      {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT"}]
        smserverlogic.SmStartRequest(server, second_request, True, False).process_request()
        time.sleep(5)
        self.assertEqual(len(context.get_service("TEST_ONE").status()), 2)
        self.assertEqual(len(context.get_service("DROPWIZARD_NEXUS_END_TO_END_TEST").status()), 2)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 2)

        # stop does not currently work for extern
        # smserverlogic.SmStopRequest(SERVER, request).process_request()
        context.kill_everything()
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
        context.kill("FAKE_NEXUS")
Пример #34
0
    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()
Пример #35
0
    def test_play_with_append_args(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False,
                            False)
        context.kill_everything()

        # Start up fake nexus first
        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)

        server = smserverlogic.SmServer(
            SmApplication(config_dir_override, None))
        request = dict()
        request["testId"] = "foo"
        request["services"] = [{
            "serviceName": "PLAY_NEXUS_END_TO_END_TEST",
            "runFrom": "SNAPSHOT",
            "appendArgs": ["-Dfoo=bar"]
        }]
        smserverlogic.SmStartRequest(server, request, True,
                                     False).process_request()
        time.sleep(5)
        self.assertEqual(
            len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)
        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)
        context.kill_everything()
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
Пример #36
0
 def test_start_and_stop_one_with_append_args(self):
     context = SmContext(SmApplication(self.config_dir_override), None, False, False)
     actions.start_one(context, "TEST_FOUR", False, True, False, None, None, ["2"])
     self.waitForCondition((lambda : len(context.get_service("TEST_FOUR").status())), 1)
     context.kill("TEST_FOUR", True)
     self.assertEqual(context.get_service("TEST_FOUR").status(), [])