aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java
blob: 64f4d6150dd4a10099611d1e3bbd30ef59fac972 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.deployment;

import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * @author jonmv
 */
public class JobTypeTest {

    @Test
    public void test() {
        for (JobType type : JobType.values()) {
            if (type.isProduction()) {
                boolean match = false;
                for (JobType other : JobType.values())
                    match |=    type != other
                             && type.isTest() == other.isDeployment()
                             && type.zones.equals(other.zones);

                assertTrue(type + " should have matching job", match);
            }
        }

        assertEquals(JobType.testUsEast3, JobType.ofSerialized("prod.us-east-3.test"));
        assertEquals(JobType.devAwsUsEast1c, JobType.ofSerialized("dev.aws-us-east-1c"));

        assertEquals(JobType.fromJobName("production-my-zone", null), JobType.prod("my-zone"));
        assertEquals(JobType.fromJobName("test-my-zone", null), JobType.test("my-zone"));
        assertEquals(JobType.fromJobName("dev-my-zone", null), JobType.dev("my-zone"));
        assertEquals(JobType.fromJobName("perf-my-zone", null), JobType.perf("my-zone"));

        assertFalse(JobType.dev("snohetta").isTest());
        assertTrue(JobType.dev("snohetta").isDeployment());
        assertFalse(JobType.dev("snohetta").isProduction());

        assertFalse(JobType.perf("snohetta").isTest());
        assertTrue(JobType.perf("snohetta").isDeployment());
        assertFalse(JobType.perf("snohetta").isProduction());

        assertTrue(JobType.deploymentTo(ZoneId.from("test", "snohetta")).isTest());
        assertTrue(JobType.deploymentTo(ZoneId.from("test", "snohetta")).isDeployment());
        assertFalse(JobType.deploymentTo(ZoneId.from("test", "snohetta")).isProduction());

        assertTrue(JobType.deploymentTo(ZoneId.from("staging", "snohetta")).isTest());
        assertTrue(JobType.deploymentTo(ZoneId.from("staging", "snohetta")).isDeployment());
        assertFalse(JobType.deploymentTo(ZoneId.from("staging", "snohetta")).isProduction());

        assertFalse(JobType.prod("snohetta").isTest());
        assertTrue(JobType.prod("snohetta").isDeployment());
        assertTrue(JobType.prod("snohetta").isProduction());

        assertTrue(JobType.test("snohetta").isTest());
        assertFalse(JobType.test("snohetta").isDeployment());
        assertTrue(JobType.test("snohetta").isProduction());
    }

}