-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: 4.22
Are you sure you want to change the base?
Vmware fix test errors #10162
Changes from all commits
845a58d
1c05c3c
d85283f
eab8e86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
|
|
@@ -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); | ||
| } | ||
|
Comment on lines
+41
to
51
|
||
|
|
||
| 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)) { | ||
|
|
@@ -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"); | ||
| } | ||
| } | ||
|
Comment on lines
+86
to
+98
|
||
|
|
||
| @Override | ||
| public TrafficType getTrafficType() { | ||
| return _trafficType; | ||
|
|
||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+35
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | |
| package com.cloud.hypervisor.vmware; | |
| import org.junit.jupiter.api.Test; | |
| import static org.junit.jupiter.api.Assertions.assertNotNull; | |
| class SpringBeanIntegrationTest { | |
| @Test | |
| void testClassIsLoadable() { | |
| assertNotNull(SpringBeanIntegrationTest.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This POM change removes all existing compile/runtime dependencies for the VMware plugin and replaces them with only JUnit Jupiter test dependencies. The module’s main sources reference many CloudStack and VMware classes, so it will no longer compile/build. Please restore the original plugin dependencies and, if JUnit 5 is required, add it in addition to (not instead of) the existing dependencies and align versions with the parent BOM/dependencyManagement.