varnishtest "VCL: test backend probe syntax"

# Check status definition
varnish v1 -vcl {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.expected_response = 204;
		}
	}
}

# Check url definition
varnish v1 -vcl {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.url = "/";
		}
	}
}

# Check request definition
varnish v1 -vcl {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.request =
			    "GET / HTTP/1.1"
			    "Host: foo.bar" ;
		}
	}
}

# Check expect_close definition
varnish v1 -errvcl {Expected "true" or "false"} {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.url = "/";
			.expect_close = faux;
		}
	}
}

varnish v1 -errvcl {Expected "true" or "false"} {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.url = "/";
			.expect_close = 1;
		}
	}
}

# Check redefinition
varnish v1 -errvcl {Probe request redefinition at:} {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.url = "/";
			.request =
			    "GET / HTTP/1.1"
			    "Host: foo.bar" ;
		}
	}
}

# Check redefinition the other way
varnish v1 -errvcl {Probe request redefinition at:} {
	backend b1 {
		.host = "${localhost}";
		.probe = {
			.request =
			    "GET / HTTP/1.1"
			    "Host: foo.bar" ;
			.url = "/";
		}
	}
}

varnish v1 -errvcl {Expected CNUM got '"120s"'} {
	backend default {
		.host = "${localhost}";
		.probe = {
			.timeout = "120s";
		}
	}
}
