1 # Copyright (C) Internet Systems Consortium, Inc. ("ISC") 2 # 3 # SPDX-License-Identifier: MPL-2.0 4 # 5 # This Source Code Form is subject to the terms of the Mozilla Public 6 # License, v. 2.0. If a copy of the MPL was not distributed with this 7 # file, you can obtain one at https://mozilla.org/MPL/2.0/. 8 # 9 # See the COPYRIGHT file distributed with this work for additional 10 # information regarding copyright ownership. 11 12 import dns.rcode 13 14 import isctest 15 16 17 def attempt_query(ns): 18 ns.rndc("flush") 19 msg = isctest.query.create("foo.example.", "A") 20 res = isctest.query.udp(msg, ns.ip) 21 if msg.rcode() == dns.rcode.NOERROR: 22 return len(res.answer) == 1 23 return False 24 25 26 def test_randomizens(ns6): 27 resolved = False 28 for _ in range(1, 25): 29 if attempt_query(ns6): 30 resolved = True 31 break 32 assert resolved 33