aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java
blob: 61eca05cc6708f41ea78fe11397196a340ab6ad5 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.deployment;

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.application.Endpoint;
import com.yahoo.vespa.hosted.controller.application.EndpointId;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;

import static com.yahoo.vespa.hosted.controller.deployment.DeploymentTester.instanceId;
import static org.junit.Assert.assertEquals;

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

    @Test
    public void testConfig() throws IOException {
        ZoneId zone = JobType.systemTest.zone(SystemName.PublicCd);
        byte[] json = new TestConfigSerializer(SystemName.PublicCd).configJson(instanceId,
                                                                               JobType.systemTest,
                                                                               true,
                                                                               Map.of(zone, List.of(Endpoint.of(ApplicationId.defaultId())
                                                                                                            .target(EndpointId.of("ai"), ClusterSpec.Id.from("qrs"),
                                                                                                                    List.of(new DeploymentId(ApplicationId.defaultId(),
                                                                                                                                             ZoneId.defaultId())))
                                                                                                            .on(Endpoint.Port.tls())
                                                                                                            .in(SystemName.main))),
                                                                               Map.of(zone, List.of("facts")));
        byte[] expected = Files.readAllBytes(Paths.get("src/test/resources/testConfig.json"));
        assertEquals(new String(SlimeUtils.toJsonBytes(SlimeUtils.jsonToSlime(expected))),
                     new String(json));
    }

}