diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-28 15:58:49 -0500 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-28 15:58:49 -0500 |
commit | cc1ea42568f360ef4093b6b8251fb4bed641a8f2 (patch) | |
tree | 1b03ece718e22d5610c52310672495ae257c5bff /application/src | |
parent | 42386c87f27961e2c94672e3203b6f43f5f29e04 (diff) |
Note precisely what works
Diffstat (limited to 'application/src')
2 files changed, 32 insertions, 25 deletions
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java index 75c18f29b29..66a7ae579fa 100644 --- a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java +++ b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java @@ -1,24 +1,19 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.application.container; -import com.sun.xml.bind.api.impl.NameConverter; import com.yahoo.application.Application; import com.yahoo.application.Networking; import com.yahoo.application.container.handler.Request; import com.yahoo.application.container.handler.Response; -import com.yahoo.container.jdisc.HttpRequest; -import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; +import org.junit.Ignore; import org.junit.Test; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; import java.net.URLEncoder; import java.nio.charset.CharacterCodingException; import java.nio.charset.StandardCharsets; -import java.util.Map; import static org.junit.Assert.assertEquals; @@ -30,31 +25,45 @@ import static org.junit.Assert.assertEquals; public class ContainerModelEvaluationTest { @Test + @Ignore // This should ideally work but may not be worth the effort public void testCreateJDiscInstanceWithModelEvaluation() { + try (JDisc jdisc = + JDisc.fromPath(new File("src/test/app-packages/model-evaluation").toPath(), + Networking.disable)) { + assertLoadedModels(jdisc); + } + } + + @Test + public void testCreateApplicationInstanceWithModelEvaluation() { try (Application application = Application.fromApplicationPackage(new File("src/test/app-packages/model-evaluation"), Networking.disable)) { - { - String expected = "{\"xgboost_xgboost_2_2\":\"http://localhost/model-evaluation/v1/xgboost_xgboost_2_2\",\"onnx_mnist_softmax\":\"http://localhost/model-evaluation/v1/onnx_mnist_softmax\",\"tensorflow_mnist_softmax_saved\":\"http://localhost/model-evaluation/v1/tensorflow_mnist_softmax_saved\",\"tensorflow_mnist_saved\":\"http://localhost/model-evaluation/v1/tensorflow_mnist_saved\",\"vespa_example\":\"http://localhost/model-evaluation/v1/vespa_example\"}"; - assertResponse("http://localhost/model-evaluation/v1", expected, application); - } + assertLoadedModels(application.getJDisc("default")); + } + } + private void assertLoadedModels(JDisc jdisc) { + { + String expected = "{\"xgboost_xgboost_2_2\":\"http://localhost/model-evaluation/v1/xgboost_xgboost_2_2\",\"onnx_mnist_softmax\":\"http://localhost/model-evaluation/v1/onnx_mnist_softmax\",\"tensorflow_mnist_softmax_saved\":\"http://localhost/model-evaluation/v1/tensorflow_mnist_softmax_saved\",\"tensorflow_mnist_saved\":\"http://localhost/model-evaluation/v1/tensorflow_mnist_saved\",\"vespa_example\":\"http://localhost/model-evaluation/v1/vespa_example\"}"; + assertResponse("http://localhost/model-evaluation/v1", expected, jdisc); + } - { - String expected = "{\"cells\":[{\"address\":{},\"value\":-8.17695}]}"; - assertResponse("http://localhost/model-evaluation/v1/xgboost_xgboost_2_2/eval", expected, application); - } + { + String expected = "{\"cells\":[{\"address\":{},\"value\":-8.17695}]}"; + assertResponse("http://localhost/model-evaluation/v1/xgboost_xgboost_2_2/eval", expected, jdisc); + } - { - // Note: The specific response value here has not been verified - String expected = "{\"cells\":[{\"address\":{\"d0\":\"0\",\"d1\":\"0\"},\"value\":-0.5066885003407351},{\"address\":{\"d0\":\"0\",\"d1\":\"1\"},\"value\":0.3912837743150205},{\"address\":{\"d0\":\"0\",\"d1\":\"2\"},\"value\":-0.12401806321703948},{\"address\":{\"d0\":\"0\",\"d1\":\"3\"},\"value\":-0.7019029168606575},{\"address\":{\"d0\":\"0\",\"d1\":\"4\"},\"value\":0.13120114146441697},{\"address\":{\"d0\":\"0\",\"d1\":\"5\"},\"value\":0.6611923203384626},{\"address\":{\"d0\":\"0\",\"d1\":\"6\"},\"value\":-0.22365810810026446},{\"address\":{\"d0\":\"0\",\"d1\":\"7\"},\"value\":-0.0740018307465809},{\"address\":{\"d0\":\"0\",\"d1\":\"8\"},\"value\":0.056492490256153896},{\"address\":{\"d0\":\"0\",\"d1\":\"9\"},\"value\":-0.18422015072393733}]}"; - assertResponse("http://localhost/model-evaluation/v1/tensorflow_mnist_saved/serving_default.y/eval?input=" + inputTensor(), expected, application); - } + { + // Note: The specific response value here has not been verified + String expected = "{\"cells\":[{\"address\":{\"d0\":\"0\",\"d1\":\"0\"},\"value\":-0.5066885003407351},{\"address\":{\"d0\":\"0\",\"d1\":\"1\"},\"value\":0.3912837743150205},{\"address\":{\"d0\":\"0\",\"d1\":\"2\"},\"value\":-0.12401806321703948},{\"address\":{\"d0\":\"0\",\"d1\":\"3\"},\"value\":-0.7019029168606575},{\"address\":{\"d0\":\"0\",\"d1\":\"4\"},\"value\":0.13120114146441697},{\"address\":{\"d0\":\"0\",\"d1\":\"5\"},\"value\":0.6611923203384626},{\"address\":{\"d0\":\"0\",\"d1\":\"6\"},\"value\":-0.22365810810026446},{\"address\":{\"d0\":\"0\",\"d1\":\"7\"},\"value\":-0.0740018307465809},{\"address\":{\"d0\":\"0\",\"d1\":\"8\"},\"value\":0.056492490256153896},{\"address\":{\"d0\":\"0\",\"d1\":\"9\"},\"value\":-0.18422015072393733}]}"; + assertResponse("http://localhost/model-evaluation/v1/tensorflow_mnist_saved/serving_default.y/eval?input=" + inputTensor(), expected, jdisc); } } - private void assertResponse(String url, String expectedResponse, Application application) { + + private void assertResponse(String url, String expectedResponse, JDisc jdisc) { try { - Response response = application.getJDisc("default").handleRequest(new Request(url)); + Response response = jdisc.handleRequest(new Request(url)); assertEquals(expectedResponse, response.getBodyAsString()); assertEquals(200, response.getStatus()); } diff --git a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java index 36657caeb40..93ca09ac5fc 100644 --- a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java +++ b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java @@ -55,17 +55,15 @@ public class ContainerProcessingTest { @Test public void requireThatBasicProcessingDoesNotTruncateBigResponse() { - final int SIZE = 50*1000; + int SIZE = 50*1000; StringBuilder foo = new StringBuilder(); for (int j = 0 ; j < SIZE ; j++) { foo.append('b'); } try (JDisc container = getContainerWithRot13()) { - final int NUM_TIMES = 100; + int NUM_TIMES = 100; for (int i = 0; i < NUM_TIMES; i++) { - - com.yahoo.application.container.handler.Response response = container.handleRequest( new com.yahoo.application.container.handler.Request("http://foo/processing/?chain=foo&title=" + foo.toString())); |