Home | History | Annotate | Line # | Download | only in resolver
      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 time
     13  1.1  christos 
     14  1.1  christos 
     15  1.1  christos import isctest
     16  1.1  christos 
     17  1.1  christos 
     18  1.1  christos def test_resolver_cache_reloadfails(ns1, templates):
     19  1.1  christos     ns1.rndc("flush")
     20  1.1  christos     msg = isctest.query.create("www.example.org.", "A")
     21  1.1  christos     res = isctest.query.udp(msg, "10.53.0.1")
     22  1.1  christos     isctest.check.noerror(res)
     23  1.1  christos     assert res.answer[0].ttl == 300
     24  1.1  christos     templates.render(
     25  1.1  christos         "ns1/named.conf", {"wrongoption": True}, template="ns1/named2.conf.j2"
     26  1.1  christos     )
     27  1.1  christos 
     28  1.1  christos     # The first reload fails, and the old cache list will be preserved
     29  1.1  christos     cmd = ns1.rndc("reload", raise_on_exception=False)
     30  1.1  christos     assert cmd.rc != 0
     31  1.1  christos 
     32  1.1  christos     templates.render("ns1/named.conf", {"wrongoption": False})
     33  1.1  christos     # The second reload succeed, and the cache is still there, as preserved
     34  1.1  christos     # from the old cache list
     35  1.1  christos     ns1.rndc("reload")
     36  1.1  christos     time.sleep(3)
     37  1.1  christos     msg = isctest.query.create("www.example.org.", "A")
     38  1.1  christos     res = isctest.query.udp(msg, "10.53.0.1")
     39  1.1  christos     isctest.check.noerror(res)
     40  1.1  christos 
     41  1.1  christos     # The ttl being lower than 300 (provided by fake authoritative) proves
     42  1.1  christos     # the cache is still in use
     43  1.1  christos     assert res.answer[0].ttl < 300
     44