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