Пример #1
0
 def test_basic_rollback(self):
     # This client gets the regular sysadmin assigned id
     client = SysAdminClient("127.0.0.1", 4000)
     client.set("network.dhcp.startip", "192.168.1.1")
     client.set("network.dhcp.endip", "192.168.1.100")
     self.assertEqual(1, client.commit().commit.commit_id)
     client.set("network.dhcp.startip", "10.0.0.1")
     client.set("network.dhcp.endip", "10.0.0.100")
     self.assertEqual(2, client.commit().commit.commit_id)
     # Can't rollback the first commit
     self.assertEqual(sysadminctl_pb2.FAILED_ROLLBACK,
                      client.rollback(1).status)
     self.assertEqual(sysadminctl_pb2.SUCCESS, client.rollback(2).status)
     self.assertEqual(
         "192.168.1.1",
         UnpackFromProto(
             client.get("network.dhcp.startip").get.kvs[0].value))
     self.assertEqual(sysadminctl_pb2.FAILED_ROLLBACK,
                      client.rollback(100).status)
Пример #2
0
 def test_new_key_rollback(self):
     #make a commit with a new key and value, ensure that a rollback can remove the key
     client = SysAdminClient("127.0.0.1", 4000)
     client.set("cheese", 42)
     self.assertEqual(1, client.commit().commit.commit_id)
     self.assertEqual(
         42, UnpackFromProto(client.get("cheese").get.kvs[0].value))
     self.assertEqual(sysadminctl_pb2.SUCCESS, client.rollback(1).status)
     self.assertEqual(sysadminctl_pb2.KEY_NOT_FOUND,
                      client.get("cheese").status)