def test_tattr_with_ttl(self): with self.driver.session("smoke/test_tattr") as session: ttl = 5 a_guid = helpers.make(session) helpers.tattr_put(session, a_guid, "cpuidle", 0, helpers.int32_value(1), ttl) self.assertEqual([[0.0, 1]], session.execute_fetch("attr get %s \"cpuidle\" [0:1]" % (a_guid,))[0][1][-1]) helpers.sleep(ttl * 2) self.assertEqual([], session.execute_fetch("attr get %s \"cpuidle\" [0:1]" % (a_guid,))[0][1][-1])
def test_tattr_types(self): with self.driver.session("smoke/test_tattr") as session: a_guid = helpers.make(session) for (attr_name, attr_time, attr_txvalue, attr_rxvalue) in [ ("string", 0, helpers.string_value("value"), "value"), ("int32", 1, helpers.int32_value(1), 1), ("int64", 2, helpers.int64_value(1), 1), ("uint32", 3, helpers.uint32_value(1), 1), ("uint64", 4, helpers.uint64_value(1), 1), ("double", 5, helpers.double_value(1), 1.0)]: helpers.tattr_put(session, a_guid, attr_name, attr_time, attr_txvalue) self.assertEqual([["t-attr", [a_guid, attr_name, [[attr_time, attr_rxvalue]]]], ["t-attr", [a_guid, attr_name, []]]], session.execute_fetch("attr get %s \"%s\" [0:6]" % (a_guid, attr_name)))