use of com.yahoo.container.core.VipStatusConfig in project vespa by vespa-engine.
the class VipStatusHandlerTestCase method testFileFound.
@Test
public final void testFileFound() throws IOException {
final File statusFile = File.createTempFile("VipStatusHandlerTestCase", null);
try {
final FileWriter writer = new FileWriter(statusFile);
final String OK = "OK\n";
writer.write(OK);
writer.close();
final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(true).statusfile(statusFile.getAbsolutePath()).noSearchBackendsImpliesOutOfService(false));
final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric);
final MockResponseHandler responseHandler = new MockResponseHandler();
final HttpRequest request = createRequest();
final BufferedContentChannel requestContent = createChannel();
handler.handleRequest(request, requestContent, responseHandler);
final ByteBuffer b = responseHandler.channel.read();
final byte[] asBytes = new byte[b.remaining()];
b.get(asBytes);
assertEquals(OK, Utf8.toString(asBytes));
} finally {
statusFile.delete();
}
}
use of com.yahoo.container.core.VipStatusConfig in project vespa by vespa-engine.
the class VipStatusHandlerTestCase method testProgrammaticallyRemovedFromRotation.
@Test
public final void testProgrammaticallyRemovedFromRotation() throws IOException {
VipStatus vipStatus = new VipStatus();
final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(false).noSearchBackendsImpliesOutOfService(true));
final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric, vipStatus);
vipStatus.removeFromRotation(this);
{
final MockResponseHandler responseHandler = new MockResponseHandler();
final HttpRequest request = createRequest();
final BufferedContentChannel requestContent = createChannel();
handler.handleRequest(request, requestContent, responseHandler);
final ByteBuffer b = responseHandler.channel.read();
final byte[] asBytes = new byte[b.remaining()];
b.get(asBytes);
assertEquals(VipStatusHandler.StatusResponse.NO_SEARCH_BACKENDS, Utf8.toString(asBytes));
}
vipStatus.addToRotation(this);
{
final MockResponseHandler responseHandler = new MockResponseHandler();
final HttpRequest request = createRequest();
final BufferedContentChannel requestContent = createChannel();
handler.handleRequest(request, requestContent, responseHandler);
final ByteBuffer b = responseHandler.channel.read();
final byte[] asBytes = new byte[b.remaining()];
b.get(asBytes);
assertEquals(VipStatusHandler.OK_MESSAGE, Utf8.toString(asBytes));
}
}
use of com.yahoo.container.core.VipStatusConfig in project vespa by vespa-engine.
the class ContainerModelBuilderTest method vip_status_handler_uses_file_for_hosted_vespa.
@Test
public void vip_status_handler_uses_file_for_hosted_vespa() throws Exception {
String servicesXml = "<services>" + "<jdisc version='1.0'>" + nodesXml + "</jdisc>" + "</services>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().applicationPackage(applicationPackage).properties(new DeployProperties.Builder().hostedVespa(true).build()).build(true));
AbstractConfigProducerRoot modelRoot = model.getRoot();
VipStatusConfig vipStatusConfig = modelRoot.getConfig(VipStatusConfig.class, "jdisc/component/status.html-status-handler");
assertTrue(vipStatusConfig.accessdisk());
assertEquals(ContainerModelBuilder.HOSTED_VESPA_STATUS_FILE, vipStatusConfig.statusfile());
}
use of com.yahoo.container.core.VipStatusConfig in project vespa by vespa-engine.
the class VipStatusHandlerTestCase method testFileNotFound.
@Test
public final void testFileNotFound() {
final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(true).statusfile("/VipStatusHandlerTestCaseFileThatReallyReallyShouldNotExist").noSearchBackendsImpliesOutOfService(false));
final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric);
final NotFoundResponseHandler responseHandler = new NotFoundResponseHandler();
final HttpRequest request = createRequest();
final BufferedContentChannel requestContent = createChannel();
handler.handleRequest(request, requestContent, responseHandler);
final ByteBuffer b = responseHandler.channel.read();
final byte[] asBytes = new byte[b.remaining()];
b.get(asBytes);
assertEquals(VipStatusHandler.StatusResponse.COULD_NOT_FIND_STATUS_FILE, Utf8.toString(asBytes));
}
use of com.yahoo.container.core.VipStatusConfig in project vespa by vespa-engine.
the class VipStatusHandlerTestCase method testHandleRequest.
@Test
public final void testHandleRequest() {
final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(false).noSearchBackendsImpliesOutOfService(false));
final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric);
final MockResponseHandler responseHandler = new MockResponseHandler();
final HttpRequest request = createRequest();
final BufferedContentChannel requestContent = createChannel();
handler.handleRequest(request, requestContent, responseHandler);
final ByteBuffer b = responseHandler.channel.read();
final byte[] asBytes = new byte[b.remaining()];
b.get(asBytes);
assertEquals(VipStatusHandler.OK_MESSAGE, Utf8.toString(asBytes));
}
Aggregations