varnishtest "Director cleanup fails on vcl.discard"

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {
	import directors;

	backend b2 {
		.host = "${s1_addr}"; .port = "${s1_port}";
	}

	backend b3 {
		.host = "${s1_addr}"; .port = "${s1_port}";
	}

	sub vcl_init {
		new foo = directors.random();
		foo.add_backend(s1, 1);
		foo.add_backend(b2, 1);
		foo.add_backend(b3, 1);
	}
	sub vcl_backend_fetch {
		set bereq.backend = foo.backend();
	}
} -start

varnish v1 -cliok "vcl.list"
varnish v1 -cliok "backend.list"

varnish v1 -vcl+backend { }
varnish v1 -cliok "vcl.list"
varnish v1 -cliok "backend.list"

varnish v1 -cliok "vcl.list"
varnish v1 -cliok "vcl.discard vcl1"

client c1 {
	txreq
	rxresp
} -run
