mirror of
https://github.com/NLnetLabs/unbound.git
synced 2024-09-21 06:37:08 +00:00
- More predictable testing for cachedb.
This commit is contained in:
parent
4f52be4db9
commit
3c3fd7a795
@ -111,6 +111,15 @@ testframe_init(struct module_env* env, struct cachedb_env* cachedb_env)
|
||||
log_err("out of memory");
|
||||
return 0;
|
||||
}
|
||||
/* Register an EDNS option (65534) to bypass the worker cache lookup
|
||||
* for testing */
|
||||
if(!edns_register_option(LDNS_EDNS_UNBOUND_CACHEDB_TESTFRAME_TEST,
|
||||
1 /* bypass cache */,
|
||||
0 /* no aggregation */, env)) {
|
||||
log_err("testframe_init, could not register test opcode");
|
||||
free(d);
|
||||
return 0;
|
||||
}
|
||||
lock_basic_init(&d->lock);
|
||||
lock_protect(&d->lock, d, sizeof(*d));
|
||||
return 1;
|
||||
@ -627,11 +636,15 @@ cachedb_extcache_store(struct module_qstate* qstate, struct cachedb_env* ie)
|
||||
* See if unbound's internal cache can answer the query
|
||||
*/
|
||||
static int
|
||||
cachedb_intcache_lookup(struct module_qstate* qstate)
|
||||
cachedb_intcache_lookup(struct module_qstate* qstate, struct cachedb_env* cde)
|
||||
{
|
||||
uint8_t* dpname=NULL;
|
||||
size_t dpnamelen=0;
|
||||
struct dns_msg* msg;
|
||||
/* for testframe bypass this lookup */
|
||||
if(cde->backend == &testframe_backend) {
|
||||
return 0;
|
||||
}
|
||||
if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,
|
||||
&dpname, &dpnamelen))
|
||||
return 0; /* no cache for these queries */
|
||||
@ -707,7 +720,7 @@ cachedb_handle_query(struct module_qstate* qstate,
|
||||
|
||||
/* lookup inside unbound's internal cache.
|
||||
* This does not look for expired entries. */
|
||||
if(cachedb_intcache_lookup(qstate)) {
|
||||
if(cachedb_intcache_lookup(qstate, ie)) {
|
||||
if(verbosity >= VERB_ALGO) {
|
||||
if(qstate->return_msg->rep)
|
||||
log_dns_msg("cachedb internal cache lookup",
|
||||
|
@ -436,7 +436,8 @@ enum sldns_enum_edns_option
|
||||
LDNS_EDNS_KEEPALIVE = 11, /* draft-ietf-dnsop-edns-tcp-keepalive*/
|
||||
LDNS_EDNS_PADDING = 12, /* RFC7830 */
|
||||
LDNS_EDNS_EDE = 15, /* RFC8914 */
|
||||
LDNS_EDNS_CLIENT_TAG = 16 /* draft-bellis-dnsop-edns-tags-01 */
|
||||
LDNS_EDNS_CLIENT_TAG = 16, /* draft-bellis-dnsop-edns-tags-01 */
|
||||
LDNS_EDNS_UNBOUND_CACHEDB_TESTFRAME_TEST = 65534
|
||||
};
|
||||
typedef enum sldns_enum_edns_option sldns_edns_option;
|
||||
|
||||
|
28
testdata/stat_values.tdir/stat_values.test
vendored
28
testdata/stat_values.tdir/stat_values.test
vendored
@ -50,7 +50,7 @@ FILTERED_STATS_FILE=filtered_stats.$$
|
||||
FOUND_STATS_FILE=found_stats.$$
|
||||
REST_STATS_FILE=rest_stats.$$
|
||||
|
||||
DEBUG=1
|
||||
DEBUG=0
|
||||
|
||||
# Write stats to $STATS_FILE.
|
||||
# Call this when you want to get stats from unbound.
|
||||
@ -95,7 +95,7 @@ check_expected_stats () {
|
||||
else
|
||||
echo "! bad expected stats:"
|
||||
cat $FILTERED_STATS_FILE
|
||||
exit 1
|
||||
end 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ check_rest_stats () {
|
||||
fi
|
||||
if grep -v "=0$" $REST_STATS_FILE; then
|
||||
echo "! bad rest stats"
|
||||
exit 1
|
||||
end 1
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
@ -426,9 +426,9 @@ wait_unbound_up unbound.log
|
||||
echo
|
||||
echo "[ Check cachedb cache miss. ]"
|
||||
echo "> dig www.example.com."
|
||||
dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
|
||||
dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
|
||||
echo "> check answer"
|
||||
if grep "0.0.0.1" outfile; then
|
||||
if grep "10.20.30.40" outfile; then
|
||||
echo "OK"
|
||||
else
|
||||
end 1
|
||||
@ -446,7 +446,7 @@ num.query.flags.AD=1
|
||||
num.query.edns.present=1
|
||||
num.query.udpout=1
|
||||
num.query.cachedb=0
|
||||
msg.cache.count=0
|
||||
msg.cache.count=1
|
||||
rrset.cache.count=1
|
||||
infra.cache.count=1
|
||||
num.answer.rcode.NOERROR=1"
|
||||
@ -454,9 +454,9 @@ num.answer.rcode.NOERROR=1"
|
||||
echo
|
||||
echo "[ Check cachedb cache hit. ]"
|
||||
echo "> dig www.example.com."
|
||||
dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
|
||||
dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
|
||||
echo "> check answer"
|
||||
if grep "0.0.0.1" outfile; then
|
||||
if grep "10.20.30.40" outfile; then
|
||||
echo "OK"
|
||||
else
|
||||
end 1
|
||||
@ -482,25 +482,25 @@ num.answer.rcode.NOERROR=1"
|
||||
echo
|
||||
echo "[ Check cachedb cache hit with stat reset ]"
|
||||
echo "> dig www.example.com."
|
||||
dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
|
||||
dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
|
||||
echo "> check answer"
|
||||
if grep "0.0.0.1" outfile; then
|
||||
if grep "10.20.30.40" outfile; then
|
||||
echo "OK"
|
||||
else
|
||||
end 1
|
||||
fi
|
||||
check_stats "\
|
||||
total.num.queries=1
|
||||
total.num.cachemiss=0
|
||||
total.num.cachehits=1
|
||||
total.num.recursivereplies=0
|
||||
total.num.cachemiss=1
|
||||
total.num.cachehits=0
|
||||
total.num.recursivereplies=1
|
||||
num.query.type.A=1
|
||||
num.query.class.IN=1
|
||||
num.query.opcode.QUERY=1
|
||||
num.query.flags.RD=1
|
||||
num.query.flags.AD=1
|
||||
num.query.edns.present=1
|
||||
num.query.cachedb=0
|
||||
num.query.cachedb=1
|
||||
msg.cache.count=1
|
||||
rrset.cache.count=1
|
||||
infra.cache.count=1
|
||||
|
Loading…
Reference in New Issue
Block a user