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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.model.provision.InMemoryProvisioner;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.NodeResources;
import com.yahoo.container.QrConfig;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.application.validation.ValidationTester;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author bratseth
*/
public class RestartChangesDefersConfigChangesTest {
@Test
public void changes_requiring_restart_defers_config_changes() {
ValidationTester tester = new ValidationTester(new InMemoryProvisioner(5,
new NodeResources(1, 3, 9, 1),
true));
VespaModel gen1 = tester.deploy(null, getServices(5, 3), Environment.prod, null).getFirst();
// Change node count - no restart
VespaModel gen2 = tester.deploy(gen1, getServices(4, 3), Environment.prod, null).getFirst();
var config2 = new QrConfig.Builder();
gen2.getContainerClusters().get("default").getContainers().get(0).getConfig(config2);
assertFalse(config2.build().restartOnDeploy());
// Change memory amount - requires restart
VespaModel gen3 = tester.deploy(gen2, getServices(4, 2), Environment.prod, null).getFirst();
var config3 = new QrConfig.Builder();
gen3.getContainerClusters().get("default").getContainers().get(0).getConfig(config3);
assertTrue(config3.build().restartOnDeploy());
}
private static String getServices(int nodes, int memory) {
return "<services version='1.0'>" +
" <container id='default' version='1.0'>" +
" <nodes count='" + nodes + "'><resources vcpu='1' memory='" + memory + "Gb' disk='9Gb'/></nodes>" +
" </container>" +
"</services>";
}
}
|