cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/2] git commit: updated refs/heads/4.8 to a13ee85
Date Fri, 09 Dec 2016 19:57:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.8 f8c9f454d -> a13ee852a


CLOUDSTACK-8908 After copying the template charging for that template is stopped


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/740179c1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/740179c1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/740179c1

Branch: refs/heads/4.8
Commit: 740179c10b6906e6c1e6016c3dd6afce46c8c74b
Parents: b704cef
Author: subhash yedugundla <venkatasubhashnaidu.yedugundla@citrix.com>
Authored: Mon Sep 28 23:05:43 2015 +0530
Committer: subhash_y <venkata.yedugundla@accelerite.com>
Committed: Tue Nov 15 14:50:13 2016 +0530

----------------------------------------------------------------------
 .../cloud/usage/dao/UsageStorageDaoImpl.java    |  3 +-
 .../usage/dao/UsageStorageDaoImplTest.java      | 88 ++++++++++++++++++++
 engine/schema/test/resources/db.properties      | 70 ++++++++++++++++
 3 files changed, 160 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/740179c1/engine/schema/src/com/cloud/usage/dao/UsageStorageDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageStorageDaoImpl.java b/engine/schema/src/com/cloud/usage/dao/UsageStorageDaoImpl.java
index 8d419e5..45337b2 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageStorageDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageStorageDaoImpl.java
@@ -41,7 +41,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO,
Long> im
     public static final Logger s_logger = Logger.getLogger(UsageStorageDaoImpl.class.getName());
 
     protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage
WHERE account_id = ? AND id = ? AND storage_type = ?";
-    protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ?
WHERE account_id = ? AND id = ? AND storage_type = ? and deleted IS NULL";
+    protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ?
WHERE account_id = ? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
     protected static final String GET_USAGE_RECORDS_BY_ACCOUNT =
         "SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created,
deleted, virtual_size " + "FROM usage_storage "
             + "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR
" + "      (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
@@ -124,6 +124,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO,
Long> im
                         pstmt.setLong(2, usage.getAccountId());
                         pstmt.setLong(3, usage.getId());
                         pstmt.setInt(4, usage.getStorageType());
+                        pstmt.setLong(5, usage.getZoneId());
                         pstmt.executeUpdate();
                     }
                 }catch (SQLException e)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/740179c1/engine/schema/test/com/cloud/usage/dao/UsageStorageDaoImplTest.java
----------------------------------------------------------------------
diff --git a/engine/schema/test/com/cloud/usage/dao/UsageStorageDaoImplTest.java b/engine/schema/test/com/cloud/usage/dao/UsageStorageDaoImplTest.java
new file mode 100644
index 0000000..4c3311f
--- /dev/null
+++ b/engine/schema/test/com/cloud/usage/dao/UsageStorageDaoImplTest.java
@@ -0,0 +1,88 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.usage.dao;
+
+import static org.mockito.Matchers.contains;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.sql.PreparedStatement;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.db.TransactionLegacy;
+import java.util.Date;
+import java.util.TimeZone;
+
+import com.cloud.usage.UsageStorageVO;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(TransactionLegacy.class)
+@PowerMockIgnore("javax.management.*")
+public class UsageStorageDaoImplTest {
+
+    @Mock
+    private PreparedStatement preparedStatementMock;
+
+    @Mock
+    private TransactionLegacy transactionMock;
+
+    @Mock
+    private  UsageStorageVO userStorageVOMock;
+
+    private final UsageStorageDaoImpl usageDao = new UsageStorageDaoImpl();
+
+    @Test
+    public void testUpdate() throws Exception {
+
+
+        long id = 21, zoneId = 31, accountId = 41;
+        int storageType = 1;
+        String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id =
? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
+        Date deleted = new Date();
+
+        PowerMockito.mockStatic(TransactionLegacy.class);
+        Mockito.when(TransactionLegacy.open(TransactionLegacy.USAGE_DB)).thenReturn(transactionMock);
+
+        when(transactionMock.prepareStatement(contains(UPDATE_DELETED))).thenReturn(preparedStatementMock);
+        when(userStorageVOMock.getAccountId()).thenReturn(accountId);
+        when(userStorageVOMock.getId()).thenReturn(id);
+        when(userStorageVOMock.getStorageType()).thenReturn(storageType);
+        when(userStorageVOMock.getZoneId()).thenReturn(zoneId);
+        when(userStorageVOMock.getDeleted()).thenReturn(deleted);
+
+
+
+        usageDao.update(userStorageVOMock);
+
+        verify(transactionMock, times(1)).prepareStatement(UPDATE_DELETED);
+        verify(preparedStatementMock, times(1)).setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"),
deleted));
+        verify(preparedStatementMock, times(1)).setLong(2, accountId);
+        verify(preparedStatementMock, times(1)).setLong(3, id);
+        verify(preparedStatementMock, times(1)).setInt(4, storageType);
+        verify(preparedStatementMock, times(1)).setLong(5, zoneId);
+        verify(preparedStatementMock, times(1)).executeUpdate();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/740179c1/engine/schema/test/resources/db.properties
----------------------------------------------------------------------
diff --git a/engine/schema/test/resources/db.properties b/engine/schema/test/resources/db.properties
new file mode 100644
index 0000000..49fd68a
--- /dev/null
+++ b/engine/schema/test/resources/db.properties
@@ -0,0 +1,70 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# management server clustering parameters, change cluster.node.IP to the machine IP address
+# in which the management server(Tomcat) is running
+cluster.node.IP=127.0.0.1
+cluster.servlet.port=9090
+region.id=1
+
+# CloudStack database settings
+db.cloud.username=cloud
+db.cloud.password=cloud
+db.root.password=
+db.cloud.host=localhost
+db.cloud.port=3306
+db.cloud.name=cloud
+
+# CloudStack database tuning parameters
+db.cloud.maxActive=250
+db.cloud.maxIdle=30
+db.cloud.maxWait=10000
+db.cloud.autoReconnect=true
+db.cloud.validationQuery=SELECT 1
+db.cloud.testOnBorrow=true
+db.cloud.testWhileIdle=true
+db.cloud.timeBetweenEvictionRunsMillis=40000
+db.cloud.minEvictableIdleTimeMillis=240000
+db.cloud.poolPreparedStatements=false
+db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096
+
+# usage database settings
+db.usage.username=cloud
+db.usage.password=cloud
+db.usage.host=localhost
+db.usage.port=3306
+db.usage.name=cloud_usage
+
+# usage database tuning parameters
+db.usage.maxActive=100
+db.usage.maxIdle=30
+db.usage.maxWait=10000
+db.usage.autoReconnect=true
+
+# Simulator database settings
+db.simulator.username=cloud
+db.simulator.password=cloud
+db.simulator.host=localhost
+db.simulator.port=3306
+db.simulator.name=simulator
+db.simulator.maxActive=250
+db.simulator.maxIdle=30
+db.simulator.maxWait=10000
+db.simulator.autoReconnect=true


Mime
View raw message