Skip to content

Commit

Permalink
feat: Added a new tests for collected resources
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 24, 2023
1 parent 509fe7e commit 0827cb6
Show file tree
Hide file tree
Showing 12 changed files with 700 additions and 51 deletions.
5 changes: 0 additions & 5 deletions plugins/azure/resoto_plugin_azure/resource/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,11 +1101,6 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if vmss_id := vmss.id:
builder.add_edge(self, clazz=AzureVirtualMachineScaleSet, id=vmss_id)

# if vms := self.virtual_machines_status:
# for vm in vms:
# if vm_id := vm.id:
# builder.add_edge(self, clazz=AzureVirtualMachine, id=vm_id)


@define(eq=False, slots=False)
class AzureResourceSkuCapacity:
Expand Down
4 changes: 2 additions & 2 deletions plugins/azure/test/collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def test_collect(
) -> None:
collector = AzureSubscriptionCollector(config, Cloud(id="azure"), azure_subscription, credentials, core_feedback)
collector.collect()
assert len(collector.graph.nodes) == 454
assert len(collector.graph.edges) == 472
assert len(collector.graph.nodes) == 467
assert len(collector.graph.edges) == 493
1 change: 0 additions & 1 deletion plugins/azure/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def roundtrip_check(
# since we can not compare objects, we use the json representation to see that no information is lost
again_js = again.to_json()
assert js_repr == again_js, f"Left: {js_repr}\nRight: {again_js}"
print(resources)
return resources


Expand Down
20 changes: 20 additions & 0 deletions plugins/azure/test/files/network/loadBalancers.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@
"type": "Microsoft.Network/loadBalancers/backendAddressPools",
"properties": {
"provisioningState": "Succeeded",
"virtualNetwork": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1"
},
"loadBalancingRules": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/loadBalancingRules/rulelb"
}
]
}
},
{
"name": "telb",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/telb",
"etag": "W/\"00000000-0000-0000-0000-00000000\"",
"type": "Microsoft.Network/loadBalancers/backendAddressPools",
"properties": {
"provisioningState": "Succeeded",
"virtualNetwork": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2"
},
"loadBalancingRules": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/loadBalancingRules/rulelb"
Expand Down
61 changes: 60 additions & 1 deletion plugins/azure/test/files/network/natGateways.json
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
{ "value": []}
{
"value": [
{
"name": "test-natGateway",
"sku": {
"name": "Standard"
},
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/natGateways/test-natGateway",
"location": "westus",
"properties": {
"idleTimeoutInMinutes": 5,
"provisioningState": "Succeeded",
"publicIpAddresses": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1"
}
],
"publicIpPrefixes": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1"
}
],
"subnets": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1"
}
]
},
"type": "Microsoft.Network/natGateways"
},
{
"name": "test-natGateway2",
"sku": {
"name": "Standard"
},
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/natGatewayes/test-natGateway2",
"location": "westus",
"properties": {
"idleTimeoutInMinutes": 5,
"provisioningState": "Succeeded",
"publicIpAddresses": [
{
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1"
}
],
"publicIpPrefixes": [
{
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1"
}
],
"subnets": [
{
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1"
}
]
},
"type": "Microsoft.Network/natGateways"
}
]
}
86 changes: 85 additions & 1 deletion plugins/azure/test/files/network/networkInterfaces.json
Original file line number Diff line number Diff line change
@@ -1 +1,85 @@
{ "value": []}
{
"value": [
{
"name": "test-nic",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic",
"location": "eastus",
"properties": {
"provisioningState": "Succeeded",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic/ipConfigurations/ipconfig1",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "172.20.2.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": [],
"internalDomainNameSuffix": "test.bx.internal.cloudapp.net"
},
"macAddress": "00-0D-3A-1B-C7-21",
"enableAcceleratedNetworking": true,
"disableTcpStateTracking": true,
"enableIPForwarding": false,
"vnetEncryptionSupported": false,
"networkSecurityGroup": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg"
},
"primary": true,
"virtualMachine": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1"
}
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"name": "test-nic2",
"id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/networkInterfaces/test-nic2",
"location": "eastus",
"properties": {
"provisioningState": "Succeeded",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/networkInterfaces/test-nic2/ipConfigurations/ipconfig1",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "172.20.2.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/publicIPAddresses/test-ip2"
},
"subnet": {
"id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/virtualNetworks/rgnew-vnet2/subnets/default"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableAcceleratedNetworking": true,
"disableTcpStateTracking": true,
"enableIPForwarding": false,
"vnetEncryptionSupported": false
},
"type": "Microsoft.Network/networkInterfaces"
}
]
}
Loading

0 comments on commit 0827cb6

Please sign in to comment.