• Diego dos Santos Fronza's avatar
    Fix resolver test: prefetch disabled · dd524cc8
    Diego dos Santos Fronza authored
    The previous test had two problems:
    1. It wasn't written specifically for testing what it was supposed to:
    prefetch disabled.
    2. It could fail in some circunstances if the computer's load is too
    high, due to sleeps not taking parallel tests and cpu load into account.
    
    The new test is testing prefetch disabled as follows:
    1. It asks for a txt record for a given domain and takes note of the
    record's TTL (which is 10).
    2. It sleeps for (TTL - 5) = 5 seconds, having a window of 5 seconds to
    issue new queries before the record expires from cache.
    3. Three(3) queries are executed in a row, with a interval of 1 second
    between them, and for each query we verify that the TTL in response is
    less than the previous one, thus ensuring that prefetch is disabled (if
    it were enabled this record would have been refreshed already and TTL
    would be >= the first TTL).
    
    Having a window of 5 seconds to perform 3 queries with a interval of 1
    second between them gives the test a reasonable amount of time
    to not suffer from a machine with heavy load.
    dd524cc8
tests.sh 32.8 KB