varnishtest "Abstract UDS backend: change path, drop poll"

feature abstract_uds

server s1 -listen "@${vtcid}.s1.sock" {
	non_fatal
	timeout 3
	loop 40 {
		rxreq
		txresp
		accept
	}
} -start

server s2 -listen "@${vtcid}.s2.sock" {
	non_fatal
	timeout 3
	loop 40 {
		rxreq
		txresp
		accept
	}
} -start

varnish v1 -arg "-a @${vtcid}.v1.sock" -vcl {
	probe default {
		.window = 8;
		.initial = 7;
		.threshold = 8;
		.interval = 0.1s;
	}
	backend s1 {
		.path = "@${vtcid}.s2.sock";
	}
} -start

delay 1

varnish v1 -vcl {
	probe default {
		.window = 8;
		.initial = 7;
		.threshold = 8;
		.interval = 0.1s;
	}
	backend s1 {
		.path = "@${vtcid}.s1.sock";
	}
} -cliok "vcl.use vcl2" -cliok "vcl.discard vcl1"

delay 1

varnish v1 -vcl {
	backend s1 {
		.path = "@${vtcid}.s1.sock";
	}
} -cliok "vcl.use vcl3" -cliok "vcl.discard vcl2"

delay 1

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

server s1 -break {
	rxreq
	expect req.url == /foo
	txresp -bodylen 4
} -start

delay 1

client c1 -connect "@${vtcid}.v1.sock" {
	txreq -url /foo
	rxresp
	txreq -url /foo
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 4
} -run

########################################
# coverage

varnish v1 -errvcl {Backend path: The empty abstract socket name is not supported} {
	backend s1 {
		.path = "@";
	}
}

shell -err -expect "Error: Got no socket(s) for @" \
	"varnishd -n ${tmpdir}/v0 -a @ -b None"