3131import org .mockito .runners .MockitoJUnitRunner ;
3232
3333import com .cloud .agent .AgentManager ;
34+ import com .cloud .alert .AlertManager ;
3435import com .cloud .agent .api .FenceAnswer ;
3536import com .cloud .agent .api .FenceCommand ;
3637import com .cloud .exception .AgentUnavailableException ;
@@ -50,6 +51,8 @@ public class KVMFencerTest {
5051 @ Mock
5152 AgentManager agentManager ;
5253 @ Mock
54+ AlertManager alertMgr ;
55+ @ Mock
5356 ResourceManager resourceManager ;
5457
5558 KVMFencer fencer ;
@@ -58,6 +61,7 @@ public class KVMFencerTest {
5861 public void setup () {
5962 fencer = new KVMFencer ();
6063 fencer ._agentMgr = agentManager ;
64+ fencer ._alertMgr = alertMgr ;
6165 fencer ._hostDao = hostDao ;
6266 fencer ._resourceMgr = resourceManager ;
6367 }
@@ -67,6 +71,8 @@ public void testWithSingleHost() {
6771 HostVO host = Mockito .mock (HostVO .class );
6872 Mockito .when (host .getClusterId ()).thenReturn (1l );
6973 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .KVM );
74+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
75+ Mockito .when (host .getPodId ()).thenReturn (1l );
7076 Mockito .when (host .getStatus ()).thenReturn (Status .Up );
7177 Mockito .when (host .getId ()).thenReturn (1l );
7278 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
@@ -80,6 +86,8 @@ public void testWithSingleHostDown() {
8086 HostVO host = Mockito .mock (HostVO .class );
8187 Mockito .when (host .getClusterId ()).thenReturn (1l );
8288 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .KVM );
89+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
90+ Mockito .when (host .getPodId ()).thenReturn (1l );
8391 Mockito .when (host .getStatus ()).thenReturn (Status .Down );
8492 Mockito .when (host .getId ()).thenReturn (1l );
8593 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
@@ -94,12 +102,16 @@ public void testWithHosts() throws AgentUnavailableException, OperationTimedoutE
94102 Mockito .when (host .getClusterId ()).thenReturn (1l );
95103 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .KVM );
96104 Mockito .when (host .getStatus ()).thenReturn (Status .Up );
105+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
106+ Mockito .when (host .getPodId ()).thenReturn (1l );
97107 Mockito .when (host .getId ()).thenReturn (1l );
98108
99109 HostVO secondHost = Mockito .mock (HostVO .class );
100110 Mockito .when (secondHost .getClusterId ()).thenReturn (1l );
101111 Mockito .when (secondHost .getHypervisorType ()).thenReturn (HypervisorType .KVM );
102112 Mockito .when (secondHost .getStatus ()).thenReturn (Status .Up );
113+ Mockito .when (secondHost .getDataCenterId ()).thenReturn (1l );
114+ Mockito .when (secondHost .getPodId ()).thenReturn (1l );
103115 Mockito .when (host .getId ()).thenReturn (2l );
104116
105117 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
@@ -118,12 +130,16 @@ public void testWithFailingFence() throws AgentUnavailableException, OperationTi
118130 Mockito .when (host .getClusterId ()).thenReturn (1l );
119131 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .KVM );
120132 Mockito .when (host .getStatus ()).thenReturn (Status .Up );
133+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
134+ Mockito .when (host .getPodId ()).thenReturn (1l );
121135 Mockito .when (host .getId ()).thenReturn (1l );
122136
123137 HostVO secondHost = Mockito .mock (HostVO .class );
124138 Mockito .when (secondHost .getClusterId ()).thenReturn (1l );
125139 Mockito .when (secondHost .getHypervisorType ()).thenReturn (HypervisorType .KVM );
126140 Mockito .when (secondHost .getStatus ()).thenReturn (Status .Up );
141+ Mockito .when (secondHost .getDataCenterId ()).thenReturn (1l );
142+ Mockito .when (secondHost .getPodId ()).thenReturn (1l );
127143 Mockito .when (host .getId ()).thenReturn (2l );
128144
129145 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
@@ -141,12 +157,16 @@ public void testWithTimeoutingFence() throws AgentUnavailableException, Operatio
141157 Mockito .when (host .getClusterId ()).thenReturn (1l );
142158 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .KVM );
143159 Mockito .when (host .getStatus ()).thenReturn (Status .Up );
160+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
161+ Mockito .when (host .getPodId ()).thenReturn (1l );
144162 Mockito .when (host .getId ()).thenReturn (1l );
145163
146164 HostVO secondHost = Mockito .mock (HostVO .class );
147165 Mockito .when (secondHost .getClusterId ()).thenReturn (1l );
148166 Mockito .when (secondHost .getHypervisorType ()).thenReturn (HypervisorType .KVM );
149167 Mockito .when (secondHost .getStatus ()).thenReturn (Status .Up );
168+ Mockito .when (secondHost .getDataCenterId ()).thenReturn (1l );
169+ Mockito .when (secondHost .getPodId ()).thenReturn (1l );
150170 Mockito .when (host .getId ()).thenReturn (2l );
151171
152172 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
@@ -165,6 +185,8 @@ public void testWithSingleNotKVM() {
165185 Mockito .when (host .getHypervisorType ()).thenReturn (HypervisorType .Any );
166186 Mockito .when (host .getStatus ()).thenReturn (Status .Down );
167187 Mockito .when (host .getId ()).thenReturn (1l );
188+ Mockito .when (host .getDataCenterId ()).thenReturn (1l );
189+ Mockito .when (host .getPodId ()).thenReturn (1l );
168190 VirtualMachine virtualMachine = Mockito .mock (VirtualMachine .class );
169191
170192 Mockito .when (resourceManager .listAllHostsInCluster (1l )).thenReturn (Collections .singletonList (host ));
0 commit comments