vtest "Test expiry callbacks"

server s1 {
	rxreq
	txresp
} -start

vinyl v1 -vcl+backend {} -start

vinyl v1 -cliok "param.set debug +vclrel"

logexpect l1 -v v1 -g raw {
	expect * 0 Debug "Subscribed to Object Events"
	expect * 0 Debug "Object Event: insert 0x[0-9a-f]+"
	expect * 0 Debug "Object Event: expire 0x[0-9a-f]+"
	expect * 0 Debug "Unsubscribed from Object Events"
} -start

vinyl v1 -vcl+backend {
	import debug;

	sub vcl_init {
		debug.register_obj_events();
	}

	sub vcl_recv {
		if (req.method == "PURGE") {
			return (purge);
		}
	}
}

client c1 {
	txreq
	rxresp
	expect resp.status == 200

	txreq -req PURGE
	rxresp
} -run
vinyl v1 -expect n_object == 0

vinyl v1 -vcl+backend {}
vinyl v1 -cliok "vcl.discard vcl2"
vinyl v1 -cliok "debug.vmod"
vinyl v1 -cliok "vcl.list"
vinyl v1 -expect vmods == 0

logexpect l1 -wait
