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 random 13 import threading 14 15 import dns.update 16 import pytest 17 18 pytestmark = pytest.mark.extra_artifacts( 19 [ 20 "K*", 21 "*.out*", 22 "*/*.out*", 23 "ns*/K*", 24 "ns*/dsset-*", 25 "ns*/*.bk", 26 "ns*/*.db", 27 "ns*/*.jbk", 28 "ns*/*.jnl", 29 "ns*/*.nzd", 30 "ns*/*.signed", 31 "ns*/trusted.conf", 32 "ns3/delayedkeys.conf", 33 "ns3/removedkeys", 34 ] 35 ) 36 37 38 def worker(server, count) -> None: 39 zone = "incremental-updates" 40 for i in range(count): 41 try: 42 sub = random.randrange(1000000) 43 update_msg = dns.update.UpdateMessage(zone) 44 update_msg.add(f"a-{sub}-{i}.{zone}.", 300, "A", "10.0.0.1") 45 server.nsupdate(update_msg) 46 except Exception: # pylint: disable=broad-exception-caught 47 break 48 49 50 def test_inline_incremental_updates(ns3): 51 """ 52 Flood the server with updates to check how 'receive secure serial' 53 is coping with quick incremental updates. 54 """ 55 threads_n = 10 56 updates_n = 10 57 threads = [ 58 threading.Thread(target=worker, args=(ns3, updates_n), daemon=True) 59 for _ in range(threads_n) 60 ] 61 62 for thread in threads: 63 thread.start() 64 for thread in threads: 65 thread.join() 66