blob: 4c1c162214028d77855540042c9f05b8b535c6f0 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.handler;
import static org.junit.Assert.*;
import org.junit.Test;
/**
* Smoke test that VipStatus has the right basic logic.
*
* @author steinar
*/
public class VipStatusTestCase {
@Test
public void testVipStatusWorksWithClusters() {
ClustersStatus clustersStatus = new ClustersStatus();
clustersStatus.setContainerHasClusters(true);
VipStatus v = new VipStatus(clustersStatus);
String cluster1 = new String("a");
String cluster2 = new String("b");
String cluster3 = new String("c");
// initial state
assertFalse(v.isInRotation());
// one cluster becomes up
v.addToRotation(cluster1);
assertTrue(v.isInRotation());
// all clusters down
v.removeFromRotation(cluster1);
v.removeFromRotation(cluster2);
v.removeFromRotation(cluster3);
assertFalse(v.isInRotation());
// some clusters down
v.addToRotation(cluster2);
assertTrue(v.isInRotation());
// all clusters up
v.addToRotation(cluster1);
v.addToRotation(cluster3);
assertTrue(v.isInRotation());
// and down again
v.removeFromRotation(cluster1);
v.removeFromRotation(cluster2);
v.removeFromRotation(cluster3);
assertFalse(v.isInRotation());
}
}
|