summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/config/model/ModelNameCollisionTest.java
blob: 08f18331d1ca9fbb16ab26837899eaf235b4a56e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model;

import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.io.IOUtils;
import com.yahoo.path.Path;
import com.yahoo.vespa.model.VespaModel;
import org.junit.After;
import org.junit.Test;
import org.xml.sax.SAXException;

import java.io.IOException;

import static org.junit.Assert.assertEquals;

/**
 * @author bratseth
 */
public class ModelNameCollisionTest {

    private static final Path appDir = Path.fromString("src/test/cfg/application/ml_serving_name_collision");

    @After
    public void removeGeneratedModelFiles() {
        IOUtils.recursiveDeleteDir(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile());
    }

    @Test
    public void testMl_ServingApplication() throws SAXException, IOException {
        ApplicationPackageTester tester = ApplicationPackageTester.create(appDir.toString());
        try {
            new VespaModel(tester.app());
        }
        catch (IllegalArgumentException e) {
            assertEquals("The models in " +
                         appDir + "/models/parent/mnist_softmax.onnx and " +
                         appDir + "/models/parent/mnist_softmax" +
                         " both resolve to the model name 'parent_mnist_softmax'",
                         e.getMessage());
        }
    }

}