Skip to content

Vmware fix test errors #10162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions incubator-taverna-language
Submodule incubator-taverna-language added at 1a823c
54 changes: 15 additions & 39 deletions plugins/hypervisors/vmware/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-hypervisor-vmware</artifactId>
<name>Apache CloudStack Plugin - Hypervisor VMware</name>
Expand All @@ -27,48 +27,24 @@
<version>4.21.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<dependencies>
<!-- Other dependencies can be listed here -->

<!-- JUnit Dependencies for Testing -->
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-vmware-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-secondary-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-storage</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-orchestration</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.cloud.com.vmware</groupId>
<artifactId>vmware-vim25</artifactId>
<version>${cs.vmware.api.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.org.apache.xml.internal</groupId>
<artifactId>resolver</artifactId>
<version>20050927</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.cloud.com.vmware</groupId>
<artifactId>vmware-pbm</artifactId>
<version>${cs.vmware.api.version}</version>
<scope>compile</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// 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
// 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
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network;
Expand All @@ -34,30 +34,22 @@ public class VmwareTrafficLabel implements TrafficLabel {
VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
String _vSwitchName = DEFAULT_VSWITCH_NAME;
String _vlanId = Vlan.UNTAGGED;
boolean _isPrimaryNic = true; // Flag to identify if this is a primary NIC
int _rateLimit = 1000; // Default rate limit in Mbps
int _guaranteedBandwidth = 500; // Default guaranteed bandwidth in Mbps

public VmwareTrafficLabel(String networkLabel, TrafficType trafficType, VirtualSwitchType defVswitchType) {
public VmwareTrafficLabel(String networkLabel, TrafficType trafficType, VirtualSwitchType defVswitchType, boolean isPrimaryNic) {
_trafficType = trafficType;
_isPrimaryNic = isPrimaryNic;
_parseLabel(networkLabel, defVswitchType);
}

public VmwareTrafficLabel(String networkLabel, TrafficType trafficType) {
public VmwareTrafficLabel(String networkLabel, TrafficType trafficType, boolean isPrimaryNic) {
_trafficType = trafficType;
_isPrimaryNic = isPrimaryNic;
_parseLabel(networkLabel, VirtualSwitchType.StandardVirtualSwitch);
}

public VmwareTrafficLabel(TrafficType trafficType, VirtualSwitchType defVswitchType) {
_trafficType = trafficType; // Define traffic label with specific traffic type
_parseLabel(null, defVswitchType);
}

public VmwareTrafficLabel(TrafficType trafficType) {
_trafficType = trafficType; // Define traffic label with specific traffic type
_parseLabel(null, VirtualSwitchType.StandardVirtualSwitch);
}

public VmwareTrafficLabel() {
}

private void _parseLabel(String networkLabel, VirtualSwitchType defVswitchType) {
// Set defaults for label in case of distributed vSwitch
if (defVswitchType.equals(VirtualSwitchType.VMwareDistributedVirtualSwitch)) {
Expand Down Expand Up @@ -91,6 +83,20 @@ private void _parseLabel(String networkLabel, VirtualSwitchType defVswitchType)
}
}

public void applyTrafficShaping() {
// Ensure traffic shaping is applied to secondary NICs
if (!_isPrimaryNic) {
// Apply lower rate limits or minimum bandwidth guarantees for secondary NICs
System.out.println("Applying traffic shaping to secondary NIC:");
System.out.println("Rate Limit: " + _rateLimit + " Mbps");
System.out.println("Guaranteed Bandwidth: " + _guaranteedBandwidth + " Mbps");
} else {
// For primary NIC, apply normal rate limits
System.out.println("Applying traffic shaping to primary NIC:");
System.out.println("Rate Limit: " + _rateLimit + " Mbps");
}
}

@Override
public TrafficType getTrafficType() {
return _trafficType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.mockito.Mockito.*;

@SpringBootTest
class ConfigurationServerTest {

@Mock
private ManagementServerHostPeerDao managementServerHostPeerDao;

@Mock
private ConfigurationDao configurationDao;

@Mock
private ConfigurationServer configurationServer;

@InjectMocks
private SomeService service; // The service you're testing, which interacts with the beans

@Test
void testGetConfiguration() {
// Arrange (setup mocks)
when(configurationDao.getConfiguration()).thenReturn(new Configuration());

// Act (execute method)
Configuration result = configurationServer.getConfiguration();

// Assert (verify results)
verify(configurationDao).getConfiguration(); // Verify that the method was called
assertNotNull(result); // Assert that the result is not null
}
}
Loading
Loading