Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions plugins/storage/image/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/image/sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/image/swift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/volume/cloudbyte/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/volume/datera/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/volume/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.cloud.agent.api.ModifyStoragePoolAnswer;
import com.cloud.agent.api.ModifyStoragePoolCommand;
import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.exception.StorageConflictException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
Expand All @@ -32,7 +33,6 @@
import com.cloud.storage.Storage;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StorageManagerImpl;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.dao.StoragePoolHostDao;
import junit.framework.TestCase;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
Expand All @@ -45,17 +45,18 @@
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.provider.DefaultHostListener;
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -64,8 +65,6 @@
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
Expand All @@ -77,7 +76,6 @@ public class CloudStackPrimaryDataStoreLifeCycleImplTest extends TestCase {
@InjectMocks
PrimaryDataStoreLifeCycle _cloudStackPrimaryDataStoreLifeCycle = new CloudStackPrimaryDataStoreLifeCycleImpl();

@Spy
@InjectMocks
StorageManager storageMgr = new StorageManagerImpl();

Expand All @@ -93,9 +91,8 @@ public class CloudStackPrimaryDataStoreLifeCycleImplTest extends TestCase {
@Mock
DataStoreProviderManager _dataStoreProviderMgr;

@Spy
@InjectMocks
HypervisorHostListener hostListener = new DefaultHostListener();
@Mock
HypervisorHostListener hostListener;

@Mock
StoragePoolHostDao storagePoolHostDao;
Expand All @@ -121,10 +118,16 @@ public class CloudStackPrimaryDataStoreLifeCycleImplTest extends TestCase {
@Mock
PrimaryDataStoreHelper primaryDataStoreHelper;

AutoCloseable closeable;

@Before
public void initMocks() {
public void initMocks() throws StorageConflictException {
closeable = MockitoAnnotations.openMocks(this);

MockitoAnnotations.initMocks(this);
ReflectionTestUtils.setField(storageMgr, "_storagePoolDao", primaryStoreDao);
ReflectionTestUtils.setField(storageMgr, "_dataStoreProviderMgr", _dataStoreProviderMgr);
ReflectionTestUtils.setField(storageMgr, "_dataStoreMgr", _dataStoreMgr);
ReflectionTestUtils.setField(_cloudStackPrimaryDataStoreLifeCycle, "storageMgr", storageMgr);

List<HostVO> hostList = new ArrayList<HostVO>();
HostVO host1 = new HostVO(1L, "aa01", Host.Type.Routing, "192.168.1.1", "255.255.255.0", null, null, null, null, null, null, null, null, null, null,
Expand All @@ -141,30 +144,31 @@ public void initMocks() {
when(store.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem);
when(store.isShared()).thenReturn(true);
when(store.getName()).thenReturn("newPool");
when(store.getStorageProviderName()).thenReturn("default");


when(_dataStoreProviderMgr.getDataStoreProvider(anyString())).thenReturn(dataStoreProvider);
when(dataStoreProvider.getName()).thenReturn("default");
((StorageManagerImpl)storageMgr).registerHostListener("default", hostListener);

when(hostListener.hostConnect(Mockito.anyLong(), Mockito.anyLong())).thenReturn(true);
storageMgr.registerHostListener("default", hostListener);


when(_resourceMgr.listAllUpHosts(eq(Host.Type.Routing), anyLong(), anyLong(), anyLong())).thenReturn(hostList);
when(agentMgr.easySend(anyLong(), Mockito.any(ModifyStoragePoolCommand.class))).thenReturn(answer);
when(answer.getResult()).thenReturn(true);
when(answer.getPoolInfo()).thenReturn(info);

when(info.getLocalPath()).thenReturn("/mnt/1");
when(info.getCapacityBytes()).thenReturn(0L);
when(info.getAvailableBytes()).thenReturn(0L);

when(storagePoolHostDao.findByPoolHost(anyLong(), anyLong())).thenReturn(null);
when(primaryStoreDao.findById(anyLong())).thenReturn(storagePool);
when(primaryStoreDao.update(anyLong(), Mockito.any(StoragePoolVO.class))).thenReturn(true);
when(primaryDataStoreHelper.attachCluster(Mockito.any(DataStore.class))).thenReturn(null);
}

@After
public void tearDown() throws Exception {
closeable.close();
}

@Test
public void testAttachCluster() throws Exception {
_cloudStackPrimaryDataStoreLifeCycle.attachCluster(store, new ClusterScope(1L, 1L, 1L));
verify(storagePoolHostDao,times(2)).persist(Mockito.any(StoragePoolHostVO.class));

Assert.assertTrue(_cloudStackPrimaryDataStoreLifeCycle.attachCluster(store, new ClusterScope(1L, 1L, 1L)));
}
}
3 changes: 0 additions & 3 deletions plugins/storage/volume/linstor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/volume/nexenta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public void testIsIscsiTargetGroupExists() {
when(client.execute(ListOfStringsNmsResponse.class, "stmf", "list_targetgroups")).thenReturn(null);
assertFalse(appliance.isIscsiTargetGroupExists(targetGroup));

when(client.execute(ListOfIscsiTargetsNmsResponse.class, "stmf", "list_targetgroups")).thenReturn(new ListOfIscsiTargetsNmsResponse());
assertFalse(appliance.isIscsiTargetGroupExists(targetGroup));

LinkedList<String> result = new LinkedList<String>();
Expand Down
3 changes: 0 additions & 3 deletions plugins/storage/volume/sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;

import com.cloud.host.Host;
Expand Down Expand Up @@ -103,7 +102,7 @@ public class ScaleIOPrimaryDataStoreLifeCycleTest {
@InjectMocks
private StorageManager storageMgr = new StorageManagerImpl();

@Spy
@Mock
private HypervisorHostListener hostListener;

@InjectMocks
Expand Down