Ejemplo n.º 1
0
    def test_should_not_go_to_bed_when_app_is_new_and_has_no_hits(self):
        url = "http://{0}/.measure-tsuru-*/response_time/_search".format(ESEARCH_HOST)
        httpretty.register_uri(httpretty.POST, url,
                               body="{}", content_type="application/json", status=200)

        self.mock_app("myapp")

        app = TsuruApp(name="myapp")
        self.assertTrue(app.should_go_to_bed())
Ejemplo n.º 2
0
    def test_sleep_app(self):
        url = TsuruClientUrls.get_sleep_url("myapp", "web", TSURU_APP_PROXY_URL)
        httpretty.register_uri(httpretty.POST, url, content_type="application/json", status=200)

        self.mock_app("myapp")

        app = TsuruApp(name="myapp")
        app.sleep()

        path = re.search('^http://[^/]+(.*)$', url).group(1)
        self.assertEqual(httpretty.last_request().path, path)
Ejemplo n.º 3
0
    def test_should_not_go_to_bed_when_app_isnt_new_and_has_hits(self):
        url = "http://{0}/.measure-tsuru-*/response_time/_search".format(
            ESEARCH_HOST)
        httpretty.register_uri(httpretty.POST,
                               url,
                               body='{"hits": {"hits": [1, 2, 3]}}',
                               content_type="application/json",
                               status=200)

        self.mock_app("myapp")

        app = TsuruApp(name="myapp")
        self.assertFalse(app.should_go_to_bed())
Ejemplo n.º 4
0
    def test_stop_app(self):
        url = TsuruClientUrls.get_stop_url("myapp", "web")
        httpretty.register_uri(httpretty.POST,
                               url,
                               content_type="application/json",
                               status=200)

        self.mock_app("myapp")

        app = TsuruApp(name="myapp")
        app.stop()

        path = re.search('^http://[^/]+(.*)$', url).group(1)
        self.assertEqual(httpretty.last_request().path, path)
Ejemplo n.º 5
0
Archivo: main.py Proyecto: tsuru/morfeu
def check_sleep(app_name, dry, apps_to_sleep):
    tsuru_app = TsuruApp(name=app_name, dry=dry)
    if tsuru_app.should_go_to_bed():
        apps_to_sleep.append(tsuru_app)
Ejemplo n.º 6
0
def check_sleep(app_name, dry, apps_to_sleep):
    tsuru_app = TsuruApp(name=app_name, dry=dry)
    if tsuru_app.should_go_to_bed():
        apps_to_sleep.append(tsuru_app)
Ejemplo n.º 7
0
    def test_unicode(self):
        self.mock_app("myapp")

        app = TsuruApp(name="myapp")
        self.assertEqual(unicode(app), "myapp")