Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ protected VolumeJoinDaoImpl() {
_count = "select count(distinct id) from volume_view WHERE ";
}

protected void setThrottleRates(VolumeResponse volResponse, VolumeJoinVO volume) {
volResponse.setBytesReadRate(volume.getBytesReadRate());
volResponse.setBytesWriteRate(volume.getBytesWriteRate());
volResponse.setIopsReadRate(volume.getIopsReadRate());
volResponse.setIopsWriteRate(volume.getIopsWriteRate());
}

@Override
public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume) {
VolumeResponse volResponse = new VolumeResponse();
Expand Down Expand Up @@ -206,10 +213,7 @@ public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume)
if (view == ResponseView.Full) {
volResponse.setStorageType(volume.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
}
volResponse.setBytesReadRate(volume.getBytesReadRate());
volResponse.setBytesWriteRate(volume.getBytesReadRate());
volResponse.setIopsReadRate(volume.getIopsWriteRate());
volResponse.setIopsWriteRate(volume.getIopsWriteRate());
setThrottleRates(volResponse, volume);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

import com.cloud.api.query.vo.VolumeJoinVO;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
Expand All @@ -43,4 +45,21 @@ public void testUpdateVolumeTagInfo(){
testUpdateTagInformation(_volumeJoinDaoImpl, volume, volumeResponse);
}

@Test
public void testSetThrottleRatesMapsReadAndWriteDistinctly() {
VolumeJoinVO vol = Mockito.mock(VolumeJoinVO.class);
Mockito.when(vol.getBytesReadRate()).thenReturn(100L);
Mockito.when(vol.getBytesWriteRate()).thenReturn(200L);
Mockito.when(vol.getIopsReadRate()).thenReturn(300L);
Mockito.when(vol.getIopsWriteRate()).thenReturn(400L);

VolumeResponse response = new VolumeResponse();
_volumeJoinDaoImpl.setThrottleRates(response, vol);

Assert.assertEquals(Long.valueOf(100L), response.getBytesReadRate());
Assert.assertEquals(Long.valueOf(200L), response.getBytesWriteRate());
Assert.assertEquals(Long.valueOf(300L), response.getIopsReadRate());
Assert.assertEquals(Long.valueOf(400L), response.getIopsWriteRate());
}

}
Loading