def testMultitenacyData(self): """Test with real data to check if multitenacy is working""" p = myredis() p.insert_window_size(tenantid, windowsize) p.insert_window_size(tenantid2, windowsize) p1 = "[serverId, 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424']" p2 = "[different_server_id, 2.0, 0.48, 0.25, 0.30, '2014-03-29T19:18:26.784424']" expected = ["'serverId'", 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424'] expected2 = ["'different_server_id'", 2.0, 0.48, 0.25, 0.30, '2014-03-29T19:18:26.784424'] p11 = mylist.parselist(p1) p21 = mylist.parselist(p2) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) result = p.media(p.range(tenantid, serverid), windowsize) result2 = p.media(p.range(tenantid2, serverid2), windowsize) self.assertEqual(expected, result.data) self.assertEqual(expected2, result2.data)
def testRealInsert2(self): """test insertion of real data""" expectedvalue = ['serverId', 1.0, 0.14, '2014-03-29T19:18:25.784424'] p1 = "[serverId, 1.0, 0.14, '2014-03-29T19:18:25.784424']" r1 = mylist() r1.insert(mylist.parselist(p1)) result = r1.get() self.assertEqual(expectedvalue, result)
def testCheckTimeStampInvalid(self): """Test if the time stamp of the new element is invalid comparing to the last element.""" p = myredis() p.insert_window_size(tenantid, windowsize) p1 = "['serverId', 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424']" p2 = "['serverId', 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:30.784424']" p3 = "['serverId', 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:35.784424']" p4 = "['serverId', 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:40.784424']" p5 = ['serverId', 1.0, 0.14, 0.25, 0.30, '2014-03-30T19:18:45.784424'] expected = False p.insert(tenantid, serverid, mylist.parselist(p1)) p.insert(tenantid, serverid, mylist.parselist(p2)) p.insert(tenantid, serverid, mylist.parselist(p3)) p.insert(tenantid, serverid, mylist.parselist(p4)) result = p.check_time_stamps(tenantid, serverid, p.range(tenantid, serverid), p5) self.assertEqual(expected, result)
def testMultitenacyData(self): """Test with real data to check if multitenacy is working""" p = myredis() p.insert_window_size(tenantid, windowsize) p.insert_window_size(tenantid2, windowsize) p1 = "[serverId, 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424']" p2 = "[different_server_id, 2.0, 0.48, 0.25, 0.30, '2014-03-29T19:18:26.784424']" expected = [ "'serverId'", 1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424' ] expected2 = [ "'different_server_id'", 2.0, 0.48, 0.25, 0.30, '2014-03-29T19:18:26.784424' ] p11 = mylist.parselist(p1) p21 = mylist.parselist(p2) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid, serverid, p11) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) p.insert(tenantid2, serverid2, p21) result = p.media(p.range(tenantid, serverid), windowsize) result2 = p.media(p.range(tenantid2, serverid2), windowsize) self.assertEqual(expected, result.data) self.assertEqual(expected2, result2.data)
def testRealData(self): """Test with real data""" p = myredis() p1 = "[1.0, 0.14, 0.25, 0.30, '2014-03-29T19:18:25.784424']" expected = [] p2 = mylist.parselist(p1) p.insert(tenantid, serverid, p2) p.insert(tenantid, serverid, p2) result = p.media(p.range(tenantid, serverid), windowsize) self.assertEqual(expected, result.data)