Example #1
0
    def test_timeboard(self):
        graph = {
            "title": "test metric graph",
            "definition":
                {
                    "requests": [{"q": "testing.metric.1{host:blah.host.1}"}],
                    "viz": "timeseries",
                }
        }

        timeboard_id = dog.Timeboard.create(title='api timeboard', description='my api timeboard',
                                            graphs=[graph])['dash']['id']
        remote_timeboard = dog.Timeboard.get(timeboard_id)

        eq('api timeboard', remote_timeboard['dash']['title'])
        eq('my api timeboard', remote_timeboard['dash']['description'])
        eq(graph['definition']['requests'],
           remote_timeboard['dash']['graphs'][0]['definition']['requests'])

        graph = {
            "title": "updated test metric graph",
            "definition": {
                "requests": [{"q": "testing.metric.1{host:blah.host.1}"}],
                "viz": "timeseries",
            }
        }

        timeboard_id = dog.Timeboard.update(timeboard_id, title='updated api timeboard',
                                            description='my updated api timeboard',
                                            graphs=[graph])['dash']['id']

        # Query and ensure all is well.
        remote_timeboard = dog.Timeboard.get(timeboard_id)

        eq('updated api timeboard', remote_timeboard['dash']['title'])
        eq('my updated api timeboard', remote_timeboard['dash']['description'])

        p = graph['definition']['requests']
        eq(p, remote_timeboard['dash']['graphs'][0]['definition']['requests'])

        # Query all dashboards and make sure it's in there.

        timeboards = dog.Timeboard.get_all()['dashes']
        ids = [timeboard["id"] for timeboard in timeboards]
        assert timeboard_id in ids or str(timeboard_id) in ids

        dog.Timeboard.delete(timeboard_id)

        try:
            dog.get(timeboard_id)
        except:
            pass
        else:
            # the previous get *should* throw an exception
            assert False
Example #2
0
    def test_timeboard(self):
        graph = {
            "title": "test metric graph",
            "definition": {
                "requests": [{
                    "q": "testing.metric.1{host:blah.host.1}"
                }],
                "viz": "timeseries",
            }
        }

        timeboard_id = dog.Timeboard.create(title='api timeboard',
                                            description='my api timeboard',
                                            graphs=[graph])['dash']['id']
        remote_timeboard = dog.Timeboard.get(timeboard_id)

        eq('api timeboard', remote_timeboard['dash']['title'])
        eq('my api timeboard', remote_timeboard['dash']['description'])
        eq(graph['definition']['requests'],
           remote_timeboard['dash']['graphs'][0]['definition']['requests'])

        graph = {
            "title": "updated test metric graph",
            "definition": {
                "requests": [{
                    "q": "testing.metric.1{host:blah.host.1}"
                }],
                "viz": "timeseries",
            }
        }

        timeboard_id = dog.Timeboard.update(
            timeboard_id,
            title='updated api timeboard',
            description='my updated api timeboard',
            graphs=[graph])['dash']['id']

        # Query and ensure all is well.
        remote_timeboard = dog.Timeboard.get(timeboard_id)

        eq('updated api timeboard', remote_timeboard['dash']['title'])
        eq('my updated api timeboard', remote_timeboard['dash']['description'])

        p = graph['definition']['requests']
        eq(p, remote_timeboard['dash']['graphs'][0]['definition']['requests'])

        # Query all dashboards and make sure it's in there.

        timeboards = dog.Timeboard.get_all()['dashes']
        ids = [timeboard["id"] for timeboard in timeboards]
        assert timeboard_id in ids or str(timeboard_id) in ids

        dog.Timeboard.delete(timeboard_id)

        try:
            dog.get(timeboard_id)
        except Exception:
            pass
        else:
            # the previous get *should* throw an exception
            assert False