Skip to content

Commit 6150ea4

Browse files
committed
test: fix smoke test and service layer
1 parent 2317561 commit 6150ea4

2 files changed

Lines changed: 55 additions & 19 deletions

File tree

server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,11 @@ public void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer
599599
String supportedProtocols;
600600
String supportedTrafficTypes = null;
601601
if (purpose == FirewallRule.Purpose.Firewall) {
602-
supportedTrafficTypes = caps.get(Capability.SupportedTrafficDirection).toLowerCase();
602+
String supportedTrafficTypesStr = caps.get(Capability.SupportedTrafficDirection);
603+
if (supportedTrafficTypesStr == null) {
604+
throw new CloudRuntimeException("Supported traffic direction capability is not defined for Firewall service");
605+
}
606+
supportedTrafficTypes = supportedTrafficTypesStr.toLowerCase();
603607
}
604608

605609
if (purpose == FirewallRule.Purpose.Firewall && trafficType == FirewallRule.TrafficType.Egress) {

test/integration/smoke/test_network_extension_namespace.py

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
Renamed from ``test_network_extension_provider.py``. The canonical test file
3131
is ``test_network_extension_namespace.py``.
3232
"""
33-
import base64
3433
import json
3534
import logging
3635
import os
@@ -97,15 +96,50 @@
9796
NETWORK_CAPABILITIES_JSON = json.dumps({
9897
"services": [
9998
"Dhcp", "Dns", "UserData",
100-
"SourceNat", "StaticNat", "PortForwarding", "Firewall", "Lb"
99+
"SourceNat", "StaticNat", "PortForwarding", "Firewall", "Lb", "NetworkACL"
101100
],
102101
"capabilities": {
102+
"Lb": {
103+
"SupportedLBAlgorithms": "roundrobin,leastconn,source",
104+
"SupportedLBIsolation": "dedicated",
105+
"SupportedProtocols": "tcp,udp,tcp-proxy",
106+
"SupportedStickinessMethods": "lbcookie,appsession",
107+
"LbSchemes": "Public",
108+
"SslTermination": "false",
109+
"VmAutoScaling": "false"
110+
},
111+
"Firewall": {
112+
"TrafficStatistics": "per public ip",
113+
"SupportedProtocols": "tcp,udp,icmp",
114+
"SupportedEgressProtocols": "tcp,udp,icmp,all",
115+
"SupportedTrafficDirection": "ingress,egress",
116+
"MultipleIps": "true"
117+
},
118+
"Dns": {
119+
"AllowDnsSuffixModification": "true",
120+
"ExternalDns": "true"
121+
},
122+
"Dhcp": {
123+
"DhcpAccrossMultipleSubnets": "true"
124+
},
125+
"Gateway": {
126+
"RedundantRouter": "false"
127+
},
103128
"SourceNat": {
104129
"SupportedSourceNatTypes": "peraccount",
105130
"RedundantRouter": "false"
106131
},
107-
"Firewall": {
108-
"TrafficStatistics": "per public ip"
132+
"StaticNat": {
133+
"Supported": "true"
134+
},
135+
"PortForwarding": {
136+
"SupportedProtocols": "tcp,udp"
137+
},
138+
"UserData": {
139+
"Supported": "true"
140+
},
141+
"NetworkACL": {
142+
"SupportedProtocols": "tcp,udp,icmp"
109143
}
110144
}
111145
})
@@ -230,10 +264,9 @@ def _ssh_copy_file(host_ip, host_port, username, password, local_path, remote_pa
230264
"""Transfer *local_path* to *remote_path* on *host_ip* via SshClient."""
231265
ssh = SshClient(host_ip, int(host_port), username, password)
232266
ssh.execute("mkdir -p '%s'" % os.path.dirname(remote_path))
233-
with open(local_path, 'rb') as fh:
234-
b64 = base64.b64encode(fh.read()).decode()
235-
ssh.execute("echo '%s' | base64 -d > '%s' && chmod 755 '%s'" %
236-
(b64, remote_path, remote_path))
267+
# Use SFTP upload to avoid very large shell arguments for script content.
268+
ssh.scp(local_path, remote_path)
269+
ssh.execute("chmod 755 '%s'" % remote_path)
237270

238271

239272
# ---------------------------------------------------------------------------
@@ -484,9 +517,8 @@ def _deploy_scripts(self):
484517

485518
self.mgmt_deployer = MgmtServerDeployer(self.mgtSvrDetails,
486519
logger=self.logger)
487-
# The extension framework executes <extension-name>.sh from extension_path.
488-
extension_script = "%s.sh" % os.path.basename(self.extension_path.rstrip('/'))
489-
self._mgmt_script_path = os.path.join(self.extension_path, extension_script)
520+
# Extension path is the entrypoint file path; append .sh if omitted.
521+
self._mgmt_script_path = (self.extension_path or "").strip().rstrip('/')
490522
self.mgmt_deployer.copy_file(entry_point_src, self._mgmt_script_path)
491523
self.logger.info("network-namespace.sh deployed to mgmt at %s",
492524
self._mgmt_script_path)
@@ -659,9 +691,9 @@ def _setup_extension_nsp_offering(self, ext_name_prefix,
659691

660692
# Register extension to physical network
661693
register_details = [
662-
{"key": "hosts", "value": kvm_hosts_csv},
663-
{"key": "username", "value": self.kvm_host_configs[0].get('username', 'root')},
664-
{"key": "password", "value": self.kvm_host_configs[0].get('password', '')},
694+
{"hosts": kvm_hosts_csv},
695+
{"username": self.kvm_host_configs[0].get('username', 'root')},
696+
{"password": self.kvm_host_configs[0].get('password', '')},
665697
]
666698

667699
self.extension.register(
@@ -1000,9 +1032,9 @@ def test_05_isolated_network_full_lifecycle(self):
10001032
→ assert SSH works (namespace rebuilt, rules reapplied)
10011033
"""
10021034
# ---- Setup ----
1003-
svc = "SourceNat,StaticNat,PortForwarding,Firewall,Lb,UserData"
1035+
svc = "SourceNat,StaticNat,PortForwarding,Firewall,Lb,UserData,Dhcp,Dns"
10041036
nw_offering, _ext_name = self._setup_extension_nsp_offering(
1005-
"extnet-iso", supported_services=svc)
1037+
"extnet-isolated", supported_services=svc)
10061038
account, network, vm = self._create_account_network_vm(
10071039
nw_offering, name_suffix="iso")
10081040

@@ -1181,12 +1213,12 @@ def test_06_vpc_multi_tier_and_restart(self):
11811213
CloudStack for VPC-associated tier networks.
11821214
"""
11831215
# ---- Setup: extension + NSP + isolated offering (for reference) ----
1184-
svc = "SourceNat,StaticNat,PortForwarding,Lb,UserData"
1216+
svc = "SourceNat,StaticNat,PortForwarding,Lb,UserData,Dhcp,Dns"
11851217
_nw_offering, ext_name = self._setup_extension_nsp_offering(
11861218
"extnet-vpc", supported_services=svc)
11871219

11881220
# ---- VPC tier network offering (useVpc=on) ----
1189-
vpc_tier_svc = "SourceNat,StaticNat,PortForwarding,Lb,UserData"
1221+
vpc_tier_svc = "SourceNat,StaticNat,PortForwarding,Lb,UserData,Dhcp,Dns"
11901222
_tier_prov = {s.strip(): ext_name for s in vpc_tier_svc.split(',')}
11911223
vpc_tier_offering = NetworkOffering.create(self.apiclient, {
11921224
"name": "ExtNet-VPCTier-%s" % random_gen(),

0 commit comments

Comments
 (0)