示例#1
0
 def test_linking_two_vertexes(self):
     with self.driver.session("smoke/test_make") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         self.assertEqual([["path", [["foobar", b_guid]]]],
                          session.execute_fetch("path %s -[foobar]> ()" %
                                                (a_guid, )))
示例#2
0
 def test_path_without_arguments(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         helpers.link(session, a_guid, "foobaz", b_guid)
         answer0 = session.execute_fetch("path %s -[*]> ()" % (a_guid, ))
         answer1 = session.execute_fetch("path %s" % (a_guid, ))
         self.assertEqual(answer0, answer1)
示例#3
0
 def test_kill_with_right_node(self):
     with self.driver.session("smoke/test_kill") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         helpers.link(session, a_guid, "foobar", c_guid)
         self.assertEqual(2, session.execute_fmap(len, "path %s -[foobar]> ()" % (a_guid,)))
         helpers.kill(session, a_guid, "foobar", b_guid)
         self.assertEqual([["path", [["foobar", c_guid]]]], session.execute_fetch("path %s -[foobar]> ()" % (a_guid,)))
示例#4
0
 def test_path_without_arguments(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid  = helpers.make(session)
         b_guid  = helpers.make(session)
         c_guid  = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         helpers.link(session, a_guid, "foobaz", b_guid)
         answer0 = session.execute_fetch("path %s -[*]> ()" % (a_guid,))
         answer1 = session.execute_fetch("path %s" % (a_guid,))
         self.assertEqual(answer0, answer1)
示例#5
0
 def test_kill_without_right_node(self):
     with self.driver.session("smoke/test_kill") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         helpers.link(session, a_guid, "b", b_guid)
         helpers.link(session, a_guid, "c", c_guid)
         self.assertEqual(
             2, session.execute_fmap(len, "path %s -[*]> ()" % (a_guid, )))
         helpers.kill(session, a_guid, "b")
         self.assertEqual([["path", [["c", c_guid]]]],
                          session.execute_fetch("path %s -[*]> ()" %
                                                (a_guid, )))
示例#6
0
 def test_path_using_prefix(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         helpers.link(session, a_guid, "foobaz", c_guid)
         answer = session.execute_fetch("path %s -[foo*]> ()" % (a_guid, ))
         if (answer[0][1][0][-1] == b_guid):
             self.assertEqual([["path", [["foobar", b_guid]]],
                               ["path", [["foobaz", c_guid]]]], answer)
         else:
             self.assertEqual([["path", [["foobaz", c_guid]]],
                               ["path", [["foobar", b_guid]]]], answer)
示例#7
0
 def test_path_using_prefix(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         helpers.link(session, a_guid, "foobaz", c_guid)
         answer = session.execute_fetch("path %s -[foo*]> ()" % (a_guid,))
         if (answer[0][1][0][-1] == b_guid):
             self.assertEqual([["path",[["foobar", b_guid]]],
                               ["path",[["foobaz", c_guid]]]], answer)
         else:
             self.assertEqual([["path",[["foobaz", c_guid]]],
                               ["path",[["foobar", b_guid]]]], answer)
示例#8
0
 def test_path_with_restriction(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid  = helpers.make(session)
         b_guid  = helpers.make(session)
         c_guid  = helpers.make(session)
         d_guid  = helpers.make(session)
         helpers.link(session, a_guid, "a", b_guid)
         helpers.link(session, a_guid, "a", c_guid)
         helpers.link(session, b_guid, "x", d_guid)
         helpers.link(session, c_guid, "x", d_guid)
         answer0 = session.execute_fetch("path %s -[a]> %s -[x]> ()" % (a_guid, b_guid))
         answer1 = session.execute_fetch("path %s -[a]> %s -[x]> ()" % (a_guid, c_guid))
         self.assertEqual([["path", [["a", b_guid], ["x", d_guid]]]], answer0)
         self.assertEqual([["path", [["a", c_guid], ["x", d_guid]]]], answer1)
示例#9
0
 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])
示例#10
0
 def test_kattr_with_ttl(self):
     with self.driver.session("smoke/test_kattr") as session:
         ttl    = 5
         a_guid = helpers.make(session)
         helpers.kattr_put(session, a_guid, "foobar", helpers.string_value("foobar"), ttl)
         self.assertEqual("foobar", session.execute_fetch("attr get %s \"foobar\"" % (a_guid,))[0][1][-1])
         helpers.sleep(ttl * 2)
         self.assertIsNone(session.execute_fetch("attr get %s \"foobar\"" % (a_guid,))[0][1][-1])
示例#11
0
 def test_path_with_restriction(self):
     with self.driver.session("smoke/test_path") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         c_guid = helpers.make(session)
         d_guid = helpers.make(session)
         helpers.link(session, a_guid, "a", b_guid)
         helpers.link(session, a_guid, "a", c_guid)
         helpers.link(session, b_guid, "x", d_guid)
         helpers.link(session, c_guid, "x", d_guid)
         answer0 = session.execute_fetch("path %s -[a]> %s -[x]> ()" %
                                         (a_guid, b_guid))
         answer1 = session.execute_fetch("path %s -[a]> %s -[x]> ()" %
                                         (a_guid, c_guid))
         self.assertEqual([["path", [["a", b_guid], ["x", d_guid]]]],
                          answer0)
         self.assertEqual([["path", [["a", c_guid], ["x", d_guid]]]],
                          answer1)
示例#12
0
 def test_kattr_types(self):
     with self.driver.session("smoke/test_kattr") as session:
         a_guid = helpers.make(session)
         for (attr_name, attr_txvalue, attr_rxvalue) in [("string", helpers.string_value("value"), "value"),
                                                         ("int32", helpers.int32_value(1), 1),
                                                         ("int64", helpers.int64_value(1), 1),
                                                         ("uint32", helpers.uint32_value(1), 1),
                                                         ("uint64", helpers.uint64_value(1), 1),
                                                         ("double", helpers.double_value(1), 1.0)]:
             helpers.kattr_put(session, a_guid, attr_name, attr_txvalue)
             self.assertEqual([["k-attr", [a_guid, attr_name, attr_rxvalue]]], session.execute_fetch("attr get %s \"%s\"" % (a_guid, attr_name)))
示例#13
0
 def test_nattr_by_prefix(self):
     with self.driver.session("smoke/test_nattr") as session:
         a_guid = helpers.make(session)
         helpers.kattr_put(session, a_guid, "foobar", helpers.string_value("foobar"))
         helpers.kattr_put(session, a_guid, "foobaz", helpers.string_value("foobar"))
         helpers.kattr_put(session, a_guid, "zoobar", helpers.string_value("foobar"))
         answer = session.execute_fetch("attr kls %s \"foo*\"" % (a_guid,))
         if ("foobar" == answer[0][1][1][0]):
             self.assertEqual([["n-attr", [a_guid, ["foobar", "foobaz"]]]], answer)
         else:
             self.assertEqual([["n-attr", [a_guid, ["foobaz", "foobar"]]]], answer)
示例#14
0
 def test_tattr_must_return_null_when_there_is_no_attr(self):
     with self.driver.session("smoke/test_tattr") as session:
         a_guid = helpers.make(session)
         self.assertEqual([["t-attr", [a_guid, "cpuidle", []]]], session.execute_fetch("attr get %s \"cpuidle\" [0:1]" % (a_guid,)))
示例#15
0
 def test_nattr_must_return_an_empty_list_when_there_is_no_attrs(self):
     with self.driver.session("smoke/test_nattr") as session:
         a_guid = helpers.make(session)
         self.assertEqual([["n-attr", [a_guid, []]]], session.execute_fetch("attr kls %s \"*\"" % (a_guid,)))
示例#16
0
 def test_kattr_must_return_null_when_there_is_no_attr(self):
     with self.driver.session("smoke/test_kattr") as session:
         a_guid = helpers.make(session)
         self.assertEqual([["k-attr", [a_guid, "foobar", None]]], session.execute_fetch("attr get %s \"foobar\"" % (a_guid,)))
示例#17
0
 def test_linking_two_vertexes(self):
     with self.driver.session("smoke/test_make") as session:
         a_guid = helpers.make(session)
         b_guid = helpers.make(session)
         helpers.link(session, a_guid, "foobar", b_guid)
         self.assertEqual([["path", [["foobar", b_guid]]]], session.execute_fetch("path %s -[foobar]> ()" % (a_guid,)))