aboutsummaryrefslogtreecommitdiffstats
path: root/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
blob: b1aa2bb62ba630f804230887bb239f82f070c67b (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.cd;

import ai.vespa.cloud.ApplicationId;
import ai.vespa.cloud.Zone;
import ai.vespa.hosted.cd.internal.TestRuntimeProvider;

import java.util.ServiceLoader;
import java.util.logging.Logger;

/**
 * The place to obtain environment-dependent configuration for test of a Vespa deployment.
 *
 * @author jvenstad
 * @author mortent
 */
public interface TestRuntime {

    Logger logger = Logger.getLogger(TestRuntime.class.getName());

    static TestRuntime get() {
        TestRuntime provided = TestRuntimeProvider.getTestRuntime();
        if (provided != null) {
            logger.fine("Using test runtime from TestRuntimeProvider");
            return provided;
        }
        logger.fine("Using test runtime from ServiceLoader");
        return ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader())
                            .findFirst()
                            .orElseThrow(() -> new IllegalStateException("No TestRuntime initialized"));
    }

    Deployment deploymentToTest();

    Zone zone();

    ApplicationId application();

}