def test_indexed_event_series(self): """test a series of IndexedEvent objects.""" indexed_event_series = dict( name="availability", columns=["index", "uptime"], points=[ ["2014-07", "100%"], ["2014-08", "88%"], ["2014-09", "95%"], ["2014-10", "99%"], ["2014-11", "91%"], ["2014-12", "99%"], ["2015-01", "100%"], ["2015-02", "92%"], ["2015-03", "99%"], ["2015-04", "87%"], ["2015-05", "92%"], ["2015-06", "100%"], ] ) series = TimeSeries(indexed_event_series) wire = self._call_interop_script('indexed_event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(indexed_event_series, new_json) self.assertTrue(new_json.get('utc')) # again with more involved data availability_series = dict( name="availability", columns=["index", "uptime", "notes", "outages"], points=[ ["2014-08", 88, "", 17], ["2014-09", 100, "", 2], ["2014-09", 95, "", 6], ["2014-10", 99, "", 3], ["2014-11", 91, "", 14], ["2014-12", 99, "", 3], ["2015-01", 100, "", 0], ["2015-02", 92, "", 12], ["2015-03", 99, "Minor outage March 2", 4], ["2015-04", 87, "Planned downtime in April", 82], ["2015-05", 92, "Router failure June 12", 26], ["2015-06", 100, "", 0], ] ) series = TimeSeries(availability_series) wire = self._call_interop_script('indexed_event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(availability_series, new_json)
def test_indexed_event_series(self): """test a series of IndexedEvent objects.""" indexed_event_series = dict(name="availability", columns=["index", "uptime"], points=[ ["2014-07", "100%"], ["2014-08", "88%"], ["2014-09", "95%"], ["2014-10", "99%"], ["2014-11", "91%"], ["2014-12", "99%"], ["2015-01", "100%"], ["2015-02", "92%"], ["2015-03", "99%"], ["2015-04", "87%"], ["2015-05", "92%"], ["2015-06", "100%"], ]) series = TimeSeries(indexed_event_series) wire = self._call_interop_script('indexed_event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(indexed_event_series, new_json) self.assertTrue(new_json.get('utc')) # again with more involved data availability_series = dict( name="availability", columns=["index", "uptime", "notes", "outages"], points=[ ["2014-08", 88, "", 17], ["2014-09", 100, "", 2], ["2014-09", 95, "", 6], ["2014-10", 99, "", 3], ["2014-11", 91, "", 14], ["2014-12", 99, "", 3], ["2015-01", 100, "", 0], ["2015-02", 92, "", 12], ["2015-03", 99, "Minor outage March 2", 4], ["2015-04", 87, "Planned downtime in April", 82], ["2015-05", 92, "Router failure June 12", 26], ["2015-06", 100, "", 0], ]) series = TimeSeries(availability_series) wire = self._call_interop_script('indexed_event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(availability_series, new_json)
def test_nested_wire_format(self): """make sure nested format round trips correctly.""" data_flow = dict(name="traffic", columns=["time", "direction"], points=[[1400425947000, { 'in': 1, 'out': 2 }], [1400425948000, { 'in': 3, 'out': 4 }], [1400425949000, { 'in': 5, 'out': 6 }], [1400425950000, { 'in': 7, 'out': 8 }]]) series = TimeSeries(data_flow) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) self.assertEqual(new_series.at(0).value('direction').get('in'), 1) self.assertEqual(new_series.at(0).value('direction').get('out'), 2) self.assertEqual(new_series.at(1).value('direction').get('in'), 3) self.assertEqual(new_series.at(1).value('direction').get('out'), 4)
def test_timerange_event_series(self): """test a series with a TimerangeEvent objects.""" timerange_event_series = dict( name="outages", columns=["timerange", "title", "esnet_ticket"], points=[ [[1429673400000, 1429707600000], "BOOM", "ESNET-20080101-001"], [[1429673400000, 1429707600000], "BAM!", "ESNET-20080101-002"], ], ) series = TimeSeries(timerange_event_series) wire = self._call_interop_script('time_range_event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(timerange_event_series, new_json) self.assertTrue(new_json.get('utc')) self.assertEqual(timerange_event_series.get('name'), new_json.get('name'))
def test_event_series_with_index(self): """test indexed data, not a series of IndexedEvent.""" event_series_with_index = dict(index="1d-625", name="traffic", columns=["time", "value", "status"], points=[[1400425947000, 522, "ok"], [1400425948000, 183, "ok"], [1400425949000, 264, "fail"], [1400425950000, 935, "offline"]]) series = TimeSeries(event_series_with_index) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(event_series_with_index, new_json) self.assertTrue(new_json.get('utc')) self.assertEqual(event_series_with_index.get('index'), new_json.get('index'))
def test_event_series_with_index(self): """test indexed data, not a series of IndexedEvent.""" event_series_with_index = dict( index="1d-625", name="traffic", columns=["time", "value", "status"], points=[ [1400425947000, 522, "ok"], [1400425948000, 183, "ok"], [1400425949000, 264, "fail"], [1400425950000, 935, "offline"] ] ) series = TimeSeries(event_series_with_index) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(event_series_with_index, new_json) self.assertTrue(new_json.get('utc')) self.assertEqual(event_series_with_index.get('index'), new_json.get('index'))
def test_nested_wire_format(self): """make sure nested format round trips correctly.""" data_flow = dict( name="traffic", columns=["time", "direction"], points=[ [1400425947000, {'in': 1, 'out': 2}], [1400425948000, {'in': 3, 'out': 4}], [1400425949000, {'in': 5, 'out': 6}], [1400425950000, {'in': 7, 'out': 8}] ] ) series = TimeSeries(data_flow) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) self.assertEqual(new_series.at(0).value('direction').get('in'), 1) self.assertEqual(new_series.at(0).value('direction').get('out'), 2) self.assertEqual(new_series.at(1).value('direction').get('in'), 3) self.assertEqual(new_series.at(1).value('direction').get('out'), 4)
def test_event_series(self): """test a series that contains basic event objects.""" event_series = dict( name="traffic", columns=["time", "value", "status"], points=[ [1400425947000, 52, "ok"], [1400425948000, 18, "ok"], [1400425949000, 26, "fail"], [1400425950000, 93, "offline"] ] ) series = TimeSeries(event_series) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(event_series, new_json) self.assertTrue(new_json.get('utc')) # try something a bit fancier with different types interface_series = dict( name="star-cr5:to_anl_ip-a_v4", description="star-cr5->anl(as683):100ge:site-ex:show:intercloud", device="star-cr5", id=169, interface="to_anl_ip-a_v4", is_ipv6=False, is_oscars=False, oscars_id=None, resource_uri="", site="anl", site_device="noni", site_interface="et-1/0/0", stats_type="Standard", title=None, columns=["time", "in", "out"], points=[ [1400425947000, 52, 34], [1400425948000, 18, 13], [1400425949000, 26, 67], [1400425950000, 93, 91] ] ) series = TimeSeries(interface_series) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(interface_series, new_json) # Now with a list of events event_objects = [ Event(1429673400000, {'in': 1, 'out': 2}), Event(1429673460000, {'in': 3, 'out': 4}), Event(1429673520000, {'in': 5, 'out': 6}), ] series = TimeSeries(dict(name='events', events=event_objects)) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) for i in enumerate(event_objects): self.assertTrue(Event.same(i[1], new_series.at(i[0])))
def test_event_series(self): """test a series that contains basic event objects.""" event_series = dict(name="traffic", columns=["time", "value", "status"], points=[[1400425947000, 52, "ok"], [1400425948000, 18, "ok"], [1400425949000, 26, "fail"], [1400425950000, 93, "offline"]]) series = TimeSeries(event_series) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(event_series, new_json) self.assertTrue(new_json.get('utc')) # try something a bit fancier with different types interface_series = dict( name="star-cr5:to_anl_ip-a_v4", description="star-cr5->anl(as683):100ge:site-ex:show:intercloud", device="star-cr5", id=169, interface="to_anl_ip-a_v4", is_ipv6=False, is_oscars=False, oscars_id=None, resource_uri="", site="anl", site_device="noni", site_interface="et-1/0/0", stats_type="Standard", title=None, columns=["time", "in", "out"], points=[[1400425947000, 52, 34], [1400425948000, 18, 13], [1400425949000, 26, 67], [1400425950000, 93, 91]]) series = TimeSeries(interface_series) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) new_json = new_series.to_json() self._validate_wire_points(interface_series, new_json) # Now with a list of events event_objects = [ Event(1429673400000, { 'in': 1, 'out': 2 }), Event(1429673460000, { 'in': 3, 'out': 4 }), Event(1429673520000, { 'in': 5, 'out': 6 }), ] series = TimeSeries(dict(name='events', events=event_objects)) wire = self._call_interop_script('event', series.to_string()) new_series = TimeSeries(wire) for i in enumerate(event_objects): self.assertTrue(Event.same(i[1], new_series.at(i[0])))