From 8c301b16ff376f7a28684962524c6941877e2fed Mon Sep 17 00:00:00 2001
From: Felipe <124818914+FelipeM525@users.noreply.github.com>
Date: Mon, 2 Sep 2024 05:17:42 -0300
Subject: [PATCH 01/10] fixed incorrect label in vrs and svms (#9617)
---
ui/src/components/view/InfoCard.vue | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ui/src/components/view/InfoCard.vue b/ui/src/components/view/InfoCard.vue
index d4c0ffc77b67..24b7cce0feb2 100644
--- a/ui/src/components/view/InfoCard.vue
+++ b/ui/src/components/view/InfoCard.vue
@@ -532,7 +532,8 @@
-
{{ $t('label.serviceofferingname') }}
+
{{ $t('label.system.offering') }}
+
{{ $t('label.serviceofferingname') }}
{{ resource.serviceofferingname || resource.serviceofferingid }}
From abaf4b52ad18b71aea53604278f302a403413d30 Mon Sep 17 00:00:00 2001
From: Nicolas Vazquez
Date: Mon, 2 Sep 2024 21:04:06 -0300
Subject: [PATCH 02/10] Fix VGPU available devices listing (#9573)
* Fix VGPU available devices listing
* Missing space
* Refactor
---
.../src/main/java/com/cloud/utils/db/Filter.java | 14 +++++++++++++-
.../com/cloud/resource/ResourceManagerImpl.java | 3 ++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/framework/db/src/main/java/com/cloud/utils/db/Filter.java b/framework/db/src/main/java/com/cloud/utils/db/Filter.java
index 15161ab058f2..fb8c9ee37fcb 100644
--- a/framework/db/src/main/java/com/cloud/utils/db/Filter.java
+++ b/framework/db/src/main/java/com/cloud/utils/db/Filter.java
@@ -22,6 +22,7 @@
import com.cloud.utils.Pair;
import com.cloud.utils.ReflectUtil;
+import org.apache.commons.lang3.StringUtils;
/**
* Try to use static initialization to help you in finding incorrect
@@ -59,6 +60,11 @@ public Filter(long limit) {
_orderBy = " ORDER BY RAND() LIMIT " + limit;
}
+ public Filter(Long offset, Long limit) {
+ _offset = offset;
+ _limit = limit;
+ }
+
/**
* Note that this copy constructor does not copy offset and limit.
* @param that filter
@@ -70,6 +76,10 @@ public Filter(Filter that) {
}
public void addOrderBy(Class> clazz, String field, boolean ascending) {
+ addOrderBy(clazz, field, ascending, null);
+ }
+
+ public void addOrderBy(Class> clazz, String field, boolean ascending, String tableAlias) {
if (field == null) {
return;
}
@@ -83,7 +93,9 @@ public void addOrderBy(Class> clazz, String field, boolean ascending) {
String name = column != null ? column.name() : field;
StringBuilder order = new StringBuilder();
- if (column == null || column.table() == null || column.table().length() == 0) {
+ if (StringUtils.isNotBlank(tableAlias)) {
+ order.append(tableAlias);
+ } else if (column == null || column.table() == null || column.table().length() == 0) {
order.append(DbUtil.getTableName(clazz));
} else {
order.append(column.table());
diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
index 5d3ec62c56d3..5ba79c2d7bd9 100755
--- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
@@ -3417,7 +3417,8 @@ public boolean isHostGpuEnabled(final long hostId) {
@Override
public List listAvailableGPUDevice(final long hostId, final String groupName, final String vgpuType) {
- final Filter searchFilter = new Filter(VGPUTypesVO.class, "remainingCapacity", false, null, null);
+ Filter searchFilter = new Filter(null, null);
+ searchFilter.addOrderBy(VGPUTypesVO.class, "remainingCapacity", false, "groupId");
final SearchCriteria sc = _gpuAvailability.create();
sc.setParameters("hostId", hostId);
sc.setParameters("groupName", groupName);
From 929cfbc3e26d6865163f651c05f03742c36601b8 Mon Sep 17 00:00:00 2001
From: Wei Zhou
Date: Tue, 3 Sep 2024 12:58:16 +0200
Subject: [PATCH 03/10] Update to Debian 12 (#9627)
---
.../systemvmtemplate/scripts/configure_systemvm_services.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh
index 1a465f4999fd..1df64d114cb8 100644
--- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh
+++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh
@@ -41,7 +41,7 @@ function configure_issue() {
__?.o/ Apache CloudStack SystemVM $CLOUDSTACK_RELEASE
( )# https://cloudstack.apache.org
- (___(_) Debian GNU/Linux 11 \n \l
+ (___(_) Debian GNU/Linux 12 \n \l
EOF
}
From 0692a296ce927fe5b41736b7a28bf739a52f4dd3 Mon Sep 17 00:00:00 2001
From: Abhishek Kumar
Date: Tue, 3 Sep 2024 17:33:57 +0530
Subject: [PATCH 04/10] engine-orchestration: fix issue for empty product in vm
metadata (#9610)
Signed-off-by: Rohit Yadav
Signed-off-by: Abhishek Kumar
Co-authored-by: Rohit Yadav
---
.../java/com/cloud/vm/VirtualMachineManager.java | 2 +-
.../java/com/cloud/vm/VirtualMachineManagerImpl.java | 2 +-
.../com/cloud/vm/VirtualMachineManagerImplTest.java | 12 ++++++++++++
.../cloud/hypervisor/kvm/resource/LibvirtVMDef.java | 6 ++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java b/engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java
index 75211df5291e..e8ffd86ac4f1 100644
--- a/engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java
+++ b/engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java
@@ -96,7 +96,7 @@ public interface VirtualMachineManager extends Manager {
ConfigKey VmMetadataProductName = new ConfigKey<>("Advanced", String.class,
"vm.metadata.product", "",
"If provided, a custom product name will be used in the instance metadata. When an empty" +
- "value is set then default product name will be 'CloudStack Hypervisor'. " +
+ "value is set then default product name will be 'CloudStack Hypervisor'. " +
"A custom product name may break cloud-init functionality with CloudStack datasource. Please " +
"refer documentation",
true, ConfigKey.Scope.Zone);
diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
index 3fa27e52c090..7c107ed6f547 100755
--- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1108,7 +1108,7 @@ protected void updateVmMetadataManufacturerAndProduct(VirtualMachineTO vmTO, VMI
}
vmTO.setMetadataManufacturer(metadataManufacturer);
String metadataProduct = VmMetadataProductName.valueIn(vm.getDataCenterId());
- if (StringUtils.isBlank(metadataManufacturer)) {
+ if (StringUtils.isBlank(metadataProduct)) {
metadataProduct = String.format("CloudStack %s Hypervisor", vm.getHypervisorType().toString());
}
vmTO.setMetadataProductName(metadataProduct);
diff --git a/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java b/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
index f2bd1095c819..906cded455e3 100644
--- a/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -1272,6 +1272,7 @@ private Pair getDummyVmTOAndVm() {
false, false, "Pass");
VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
Mockito.when(vm.getDataCenterId()).thenReturn(1L);
+ Mockito.when(vm.getHypervisorType()).thenReturn(HypervisorType.KVM);
return new Pair<>(virtualMachineTO, vm);
}
@@ -1284,6 +1285,17 @@ public void testUpdateVmMetadataManufacturerAndProductDefaultManufacturer() {
Assert.assertEquals(VirtualMachineManager.VmMetadataManufacturer.defaultValue(), to.getMetadataManufacturer());
}
+ @Test
+ public void testUpdateVmMetadataManufacturerAndProductCustomManufacturerDefaultProduct() {
+ String manufacturer = "Custom";
+ overrideVmMetadataConfigValue(manufacturer, "");
+ Pair pair = getDummyVmTOAndVm();
+ VirtualMachineTO to = pair.first();
+ virtualMachineManagerImpl.updateVmMetadataManufacturerAndProduct(to, pair.second());
+ Assert.assertEquals(manufacturer, to.getMetadataManufacturer());
+ Assert.assertEquals("CloudStack KVM Hypervisor", to.getMetadataProductName());
+ }
+
@Test
public void testUpdateVmMetadataManufacturerAndProductCustomManufacturer() {
String manufacturer = UUID.randomUUID().toString();
diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index c1ea3e99717d..dfd531b1a0b6 100644
--- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -127,6 +127,9 @@ public GuestType getGuestType() {
}
public String getManufacturer() {
+ if (StringUtils.isEmpty(manufacturer)) {
+ return "Apache Software Foundation";
+ }
return manufacturer;
}
@@ -135,6 +138,9 @@ public void setManufacturer(String manufacturer) {
}
public String getProduct() {
+ if (StringUtils.isEmpty(product)) {
+ return "CloudStack KVM Hypervisor";
+ }
return product;
}
From f9c4edc66fa5492909037438ff4abdb505f03a7d Mon Sep 17 00:00:00 2001
From: Suresh Kumar Anaparti
Date: Wed, 4 Sep 2024 11:42:41 +0530
Subject: [PATCH 05/10] SystemVM template changes - updated debian version &
other changes (#9625)
* systemvm template changes, to explicitly update the module dependencies, vmware hardware version updated to 13, fsck added in grub
* Update systemvm template debian version to 12.7
---
systemvm/debian/opt/cloud/bin/setup/init.sh | 2 ++
tools/appliance/build.sh | 2 +-
tools/appliance/systemvmtemplate/scripts/configure_grub.sh | 2 +-
.../template-base_aarch64-target_aarch64.json | 4 ++--
.../systemvmtemplate/template-base_x86_64-target_aarch64.json | 4 ++--
.../systemvmtemplate/template-base_x86_64-target_x86_64.json | 4 ++--
6 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/systemvm/debian/opt/cloud/bin/setup/init.sh b/systemvm/debian/opt/cloud/bin/setup/init.sh
index ae13700fffd1..5507193c4df3 100644
--- a/systemvm/debian/opt/cloud/bin/setup/init.sh
+++ b/systemvm/debian/opt/cloud/bin/setup/init.sh
@@ -112,6 +112,8 @@ config_guest() {
fi
;;
vmware)
+ # explicitly update the module dependencies
+ depmod -a
# system time sync'd with host via vmware tools
systemctl stop ntpd
systemctl disable ntpd
diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh
index 4865842d17b4..fa5d0e853cc6 100755
--- a/tools/appliance/build.sh
+++ b/tools/appliance/build.sh
@@ -235,7 +235,7 @@ function stage_vmx() {
displayname = "${1}"
annotation = "${1}"
guestos = "otherlinux-64"
-virtualHW.version = "11"
+virtualHW.version = "13"
config.version = "8"
numvcpus = "1"
cpuid.coresPerSocket = "1"
diff --git a/tools/appliance/systemvmtemplate/scripts/configure_grub.sh b/tools/appliance/systemvmtemplate/scripts/configure_grub.sh
index 231aa764449f..f9103925b3b7 100644
--- a/tools/appliance/systemvmtemplate/scripts/configure_grub.sh
+++ b/tools/appliance/systemvmtemplate/scripts/configure_grub.sh
@@ -34,7 +34,7 @@ function configure_grub() {
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=Debian
-GRUB_CMDLINE_LINUX_DEFAULT="quiet"
+GRUB_CMDLINE_LINUX_DEFAULT="quiet fsck.mode=force fsck.repair=yes"
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 console=hvc0 earlyprintk=xen net.ifnames=0 biosdevname=0 debian-installer=en_US nomodeset"
GRUB_CMDLINE_XEN="com1=115200 console=com1"
GRUB_TERMINAL="console serial"
diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json
index 2ceadeaf7429..67493c7c6357 100644
--- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json
+++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json
@@ -32,8 +32,8 @@
"format": "qcow2",
"headless": true,
"http_directory": "http",
- "iso_checksum": "sha512:14c2ca243ee7f6e447cc4466296d974ee36645c06d72043236c3fbea78f1948d3af88d65139105a475288f270e4b636e6885143d01bdf69462620d1825e470ae",
- "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.5.0/arm64/iso-cd/debian-12.5.0-arm64-netinst.iso",
+ "iso_checksum": "sha512:fc3560bb586af14b1d77ab7c2806616916926afcbd5cb3fd5a04a5633dfd91cfbbccada1a123f1ea14c480153b731cbee72a230cea17fd9116b9df8444d8df1c",
+ "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.7.0/arm64/iso-cd/debian-12.7.0-arm64-netinst.iso",
"net_device": "virtio-net",
"output_directory": "../dist",
"qemu_binary": "qemu-system-aarch64",
diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json
index b49ed17104af..ed03fd74942c 100644
--- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json
+++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json
@@ -31,8 +31,8 @@
"format": "qcow2",
"headless": true,
"http_directory": "http",
- "iso_checksum": "sha512:14c2ca243ee7f6e447cc4466296d974ee36645c06d72043236c3fbea78f1948d3af88d65139105a475288f270e4b636e6885143d01bdf69462620d1825e470ae",
- "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.5.0/arm64/iso-cd/debian-12.5.0-arm64-netinst.iso",
+ "iso_checksum": "sha512:fc3560bb586af14b1d77ab7c2806616916926afcbd5cb3fd5a04a5633dfd91cfbbccada1a123f1ea14c480153b731cbee72a230cea17fd9116b9df8444d8df1c",
+ "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.7.0/arm64/iso-cd/debian-12.7.0-arm64-netinst.iso",
"net_device": "virtio-net",
"output_directory": "../dist",
"qemu_binary": "qemu-system-aarch64",
diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json
index 5dc2051d1275..e209d4803348 100644
--- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json
+++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json
@@ -27,8 +27,8 @@
"format": "qcow2",
"headless": true,
"http_directory": "http",
- "iso_checksum": "sha512:33c08e56c83d13007e4a5511b9bf2c4926c4aa12fd5dd56d493c0653aecbab380988c5bf1671dbaea75c582827797d98c4a611f7fb2b131fbde2c677d5258ec9",
- "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.5.0/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso",
+ "iso_checksum": "sha512:e0bd9ba03084a6fd42413b425a2d20e3731678a31fe5fb2cc84f79332129afca2ad4ec897b4224d6a833afaf28a5d938b0fe5d680983182944162c6825b135ce",
+ "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.7.0/amd64/iso-cd/debian-12.7.0-amd64-netinst.iso",
"net_device": "virtio-net",
"output_directory": "../dist",
"qemuargs": [
From 628aba618b5b7c938c494c9a7f19463d0ecce0c9 Mon Sep 17 00:00:00 2001
From: Gabriel Pordeus Santos
Date: Wed, 4 Sep 2024 03:13:25 -0300
Subject: [PATCH 06/10] add min details to search view (#9616)
---
ui/src/components/view/SearchView.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue
index 07e2d14e8bcb..0d18ab9a85c2 100644
--- a/ui/src/components/view/SearchView.vue
+++ b/ui/src/components/view/SearchView.vue
@@ -706,7 +706,7 @@ export default {
},
fetchDomains (searchKeyword) {
return new Promise((resolve, reject) => {
- api('listDomains', { listAll: true, showicon: true, keyword: searchKeyword }).then(json => {
+ api('listDomains', { listAll: true, details: 'min', showicon: true, keyword: searchKeyword }).then(json => {
const domain = json.listdomainsresponse.domain
resolve({
type: 'domainid',
From 882dea21c1fc584255bf7214a7b201a52bb9236d Mon Sep 17 00:00:00 2001
From: Felipe <124818914+FelipeM525@users.noreply.github.com>
Date: Wed, 4 Sep 2024 03:32:28 -0300
Subject: [PATCH 07/10] Update .asf.yaml (#9629)
---
.asf.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.asf.yaml b/.asf.yaml
index 8c1a5d51fdf1..4d979a188335 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -59,6 +59,7 @@ github:
- hsato03
- bernardodemarco
- abh1sar
+ - FelipeM525
protected_branches: ~
From f2a1ee57cac18904d798b400b182fa04b814cff7 Mon Sep 17 00:00:00 2001
From: NuxRo
Date: Wed, 4 Sep 2024 07:34:55 +0100
Subject: [PATCH 08/10] Update en.json (#8958)
Replace "Control Plane" with "Compute Resource"
---
ui/public/locales/en.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json
index 2e5412bf7378..c87ee0070f77 100644
--- a/ui/public/locales/en.json
+++ b/ui/public/locales/en.json
@@ -1036,7 +1036,7 @@
"label.host.alerts": "Hosts in alert state",
"label.host.name": "Host name",
"label.host.tag": "Host tag",
-"label.hostcontrolstate": "Control Plane Status",
+"label.hostcontrolstate": "Compute Resource Status",
"label.hostid": "Host",
"label.hostname": "Host",
"label.hostname.tooltip": "Destination Host. Volume should be located in local storage of this Host",
@@ -3079,7 +3079,7 @@
"message.chart.statistic.info.hypervisor.additionals": "The metrics data depend on the hypervisor plugin used for each hypervisor. The behavior can vary across different hypervisors. For instance, with KVM, metrics are real-time statistics provided by libvirt. In contrast, with VMware, the metrics are averaged data for a given time interval controlled by configuration.",
"message.guest.traffic.in.advanced.zone": "Guest Network traffic is communication between end-user Instances. Specify a range of VLAN IDs or VXLAN Network identifiers (VNIs) to carry guest traffic for each physical Network.",
"message.guest.traffic.in.basic.zone": "Guest Network traffic is communication between end-user Instances. Specify a range of IP addresses that CloudStack can assign to guest Instances. Make sure this range does not overlap the reserved system IP range.",
-"message.host.controlstate": "The Control Plane Status of this Instance is ",
+"message.host.controlstate": "The Compute Resource Status for this Instance is ",
"message.host.controlstate.retry": "Some actions on this Instance will fail, if so please wait a while and retry.",
"message.host.dedicated": "Host Dedicated",
"message.host.dedication.released": "Host dedication released.",
From 24dc3178a39d5cc4833539264abae07c1a618683 Mon Sep 17 00:00:00 2001
From: Alain-Christian Courtines
<110478358+my-code-AL@users.noreply.github.com>
Date: Tue, 3 Sep 2024 23:39:47 -0700
Subject: [PATCH 09/10] Testcases Added (#9116)
* added a news tester file and directory for GsonHelper.java. Also created a new test in OVAProcessorTest.java
* added testcase to PasswordPolicyImplTest.java
* added proper imports for GsonHelperTest.java
* expected changed based on commit response
* adhere to checkstyle ruleset
---
.../com/cloud/serializer/GsonHelperTest.java | 81 +++++++++++++++++++
.../storage/template/OVAProcessorTest.java | 20 +++++
.../cloud/user/PasswordPolicyImplTest.java | 18 +++++
3 files changed, 119 insertions(+)
create mode 100644 core/src/test/java/com/cloud/serializer/GsonHelperTest.java
diff --git a/core/src/test/java/com/cloud/serializer/GsonHelperTest.java b/core/src/test/java/com/cloud/serializer/GsonHelperTest.java
new file mode 100644
index 000000000000..e8b0b373060b
--- /dev/null
+++ b/core/src/test/java/com/cloud/serializer/GsonHelperTest.java
@@ -0,0 +1,81 @@
+// 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.serializer;
+
+import com.cloud.agent.api.to.NfsTO;
+import com.cloud.storage.DataStoreRole;
+import com.google.gson.Gson;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases to verify working order of GsonHelper.java
+ * with regards to a concrete implementation of the DataStoreTO
+ * interface
+ */
+public class GsonHelperTest {
+
+ private Gson gson;
+ private Gson gsonLogger;
+ private NfsTO nfsTO;
+
+ @Before
+ public void setUp() {
+ gson = GsonHelper.getGson();
+ gsonLogger = GsonHelper.getGsonLogger();
+ nfsTO = new NfsTO("http://example.com", DataStoreRole.Primary);
+ }
+
+ @Test
+ public void testGsonSerialization() {
+ String json = gson.toJson(nfsTO);
+ assertNotNull(json);
+ assertTrue(json.contains("\"_url\":\"http://example.com\""));
+ assertTrue(json.contains("\"_role\":\"Primary\""));
+ }
+
+ @Test
+ public void testGsonDeserialization() {
+ String json = "{\"_url\":\"http://example.com\",\"_role\":\"Primary\"}";
+ NfsTO deserializedNfsTO = gson.fromJson(json, NfsTO.class);
+ assertNotNull(deserializedNfsTO);
+ assertEquals("http://example.com", deserializedNfsTO.getUrl());
+ assertEquals(DataStoreRole.Primary, deserializedNfsTO.getRole());
+ }
+
+ @Test
+ public void testGsonLoggerSerialization() {
+ String json = gsonLogger.toJson(nfsTO);
+ assertNotNull(json);
+ assertTrue(json.contains("\"_url\":\"http://example.com\""));
+ assertTrue(json.contains("\"_role\":\"Primary\""));
+ }
+
+ @Test
+ public void testGsonLoggerDeserialization() {
+ String json ="{\"_url\":\"http://example.com\",\"_role\":\"Primary\"}";
+ NfsTO deserializedNfsTO = gsonLogger.fromJson(json, NfsTO.class);
+ assertNotNull(deserializedNfsTO);
+ assertEquals("http://example.com", deserializedNfsTO.getUrl());
+ assertEquals(DataStoreRole.Primary, deserializedNfsTO.getRole());
+ }
+}
diff --git a/core/src/test/java/com/cloud/storage/template/OVAProcessorTest.java b/core/src/test/java/com/cloud/storage/template/OVAProcessorTest.java
index 8ab546447182..8674a8df2861 100644
--- a/core/src/test/java/com/cloud/storage/template/OVAProcessorTest.java
+++ b/core/src/test/java/com/cloud/storage/template/OVAProcessorTest.java
@@ -131,5 +131,25 @@ public void testGetVirtualSize() throws Exception {
Assert.assertEquals(virtualSize, processor.getVirtualSize(mockFile));
Mockito.verify(mockFile, Mockito.times(0)).length();
}
+ @Test
+ public void testProcessWithLargeFileSize() throws Exception {
+ String templatePath = "/tmp";
+ String templateName = "large_template";
+ long virtualSize = 10_000_000_000L;
+ long actualSize = 5_000_000_000L;
+
+ Mockito.when(mockStorageLayer.exists(Mockito.anyString())).thenReturn(true);
+ Mockito.when(mockStorageLayer.getSize(Mockito.anyString())).thenReturn(actualSize);
+ Mockito.doReturn(virtualSize).when(processor).getTemplateVirtualSize(Mockito.anyString(), Mockito.anyString());
+ try (MockedConstruction