Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

07 vlan metalgateways spec field patch #36

Closed
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Execute functional tests
name: Execute functional tests for device related workflows

on:
workflow_dispatch:
Expand Down Expand Up @@ -53,9 +53,9 @@ jobs:

echo `cat equinix-functional-test/src/test/resources/device-test.properties`

- name: Run functional test.
- name: Run functional tests for DeviceOperator.
working-directory: ./equinix-functional-test
run: mvn clean package --file pom.xml
run: mvn clean test -Dtest=com.equinix.test.functional.TestDeviceOperator.java --file pom.xml
env:
FUNCTIONAL_TEST_TOKEN: ${{ github.event.inputs.token }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ github.event.inputs.project_uuid }}
61 changes: 61 additions & 0 deletions .github/workflows/run-metalgateway-functional-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Execute functional tests for MetalGateway related workflows

on:
workflow_dispatch:
inputs:
metro:
description: 'metro code where you want to deploy'
default: 'DA'
required: true
privateIpv4SubnetSize:
description: 'private ipv4 subnet size'
default: '16'
required: true
vxlan:
description: 'vxlan id'
default: '100'
required: true
token:
description: 'Users temp API KEY token (Note: delete after use)'
required: true
project_uuid:
description: 'Project UUID where to deploy instance'
required: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven

- name: Run equinix metal-java make
run: make docker_run

- name: Install equinix client
working-directory: ./equinix-openapi-metal
run: mvn clean install --file pom.xml

- name: Set env parameters amd create metalgateway-test props file
run: |
echo "metro=${{ github.event.inputs.metro }}" > equinix-functional-test/src/test/resources/metalgateway-test.properties
echo -e "\nprivateIpv4SubnetSize=${{ github.event.inputs.privateIpv4SubnetSize }}" >> equinix-functional-test/src/test/resources/metalgateway-test.properties
echo -e "\nvxlan=${{ github.event.inputs.vxlan }}" >> equinix-functional-test/src/test/resources/metalgateway-test.properties

echo `cat equinix-functional-test/src/test/resources/metalgateway-test.properties`

- name: Run functional tests for MetalGatewayOperator.
working-directory: ./equinix-functional-test
run: mvn clean test -Dtest=com.equinix.test.functional.TestMetalGatewayOperator.java --file pom.xml
env:
FUNCTIONAL_TEST_TOKEN: ${{ github.event.inputs.token }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ github.event.inputs.project_uuid }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ cd equinix-openapi-metal
mvn clean package
```

Following command executes list metro sample by consuming local jars produced after building generated metal-java client:
The following executes list metro sample by consuming local jars produced after building generated metal-java client:
```
cd ..
java -classpath "equinix-openapi-metal/target/equinix-openapi-metal-1.0.0.jar:equinix-openapi-metal/target/lib/*" examples/ListMetros.java <API KEY TOKEN>
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.equinix.functional.test;
package com.equinix.test.functional;

import com.equinix.workflow.DeviceOperator;
import com.equinix.openapi.ApiClient;
Expand All @@ -9,9 +9,7 @@
import com.equinix.openapi.metal.v1.model.DeviceCreateInput;

import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.equinix.test.functional;

import java.time.Duration;
import java.util.HashMap;
import java.util.UUID;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.equinix.openapi.ApiClient;
import com.equinix.openapi.ApiException;
import com.equinix.openapi.Configuration;
import com.equinix.openapi.auth.ApiKeyAuth;
import com.equinix.openapi.metal.v1.api.VlansApi;
import com.equinix.openapi.metal.v1.model.MetalGateway;
import com.equinix.openapi.metal.v1.model.MetalGatewayInput;
import com.equinix.openapi.metal.v1.model.VirtualNetwork;
import com.equinix.openapi.metal.v1.model.VirtualNetworkCreateInput;
import com.equinix.workflow.MetalGatewayOperator;

public class TestMetalGatewayOperator {
private static final Logger logger = LoggerFactory.getLogger(TestDeviceOperator.class);

private final String propFilename = "src/test/resources/metalgateway-test.properties";
private final String sysTokenKey = "FUNCTIONAL_TEST_TOKEN";
private final String sysProjUuidKey = "FUNCTIONAL_TEST_PROJECT_UUID";

private HashMap<String, String> props;
private MetalGatewayOperator metalGatewayOperator;
private VlansApi vlansApi;

@Before
public void setup() {
logger.info("Executing TestDMetalGatewayOperator setup...");
props = TestUtilis.ReadPropertiesFile(propFilename);

// These properties need to be added dynamically before test execution.
String token = System.getenv(sysTokenKey);

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: x_auth_token
ApiKeyAuth x_auth_token = (ApiKeyAuth) defaultClient.getAuthentication("x_auth_token");
x_auth_token.setApiKey(token);
metalGatewayOperator = new MetalGatewayOperator(defaultClient);
vlansApi = new VlansApi(defaultClient);
}

public VirtualNetwork createVlan(UUID projectId) throws ApiException {
VirtualNetworkCreateInput vlanInput=new VirtualNetworkCreateInput()
.metro(props.get("metro"))
.projectId(projectId)
.vxlan(Integer.valueOf(props.get("vxlan")));
return vlansApi.createVirtualNetwork(projectId, vlanInput);
}

public void deleteVlan(UUID vlanId) throws ApiException {
vlansApi.deleteVirtualNetwork(vlanId);
}

@Test
public void testMetalGatewayCreationAndPolling() throws ApiException, InterruptedException {
logger.info("Executing Test: testMetalGatewayCreationAndPolling");
UUID projectId = UUID.fromString(System.getenv(sysProjUuidKey));

logger.info("Creating vlan ...");
VirtualNetwork vlan = createVlan(projectId);

MetalGatewayInput metalGatewayInput = new MetalGatewayInput()
.privateIpv4SubnetSize(Integer.valueOf(props.get("privateIpv4SubnetSize")))
.virtualNetworkId(vlan.getId());

int retries = 10;
Duration wait = Duration.ofSeconds(5);
logger.info("Provisioning metal gateway with the vlan attached to it...");
MetalGateway metalGateway = metalGatewayOperator.createMetalGatewayAndPoll(metalGatewayInput, projectId, retries, wait);

UUID metalGatewayId=metalGateway.getId();
Assert.assertNotNull(metalGateway.getState());
logger.info(String.format("Metal Gateway state : %s and ID : %s", metalGateway.getState(), metalGatewayId.toString()));

String[] vlanHrefLink = metalGateway.getVirtualNetwork().getHref().split("/");
String vlanId = vlanHrefLink[vlanHrefLink.length-1];
Assert.assertEquals(vlan.getId().toString(), vlanId);
logger.info(String.format("ID of associated VLAN: %s", vlanId));

logger.info("Deprovisioning metal gateway ...");
metalGatewayOperator.deleteMetalGateway(metalGatewayId);
Assert.assertThrows(ApiException.class, () -> metalGatewayOperator.findMetalGateway(metalGatewayId));

logger.info("Deleting vlan ...");
deleteVlan(vlan.getId());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.equinix.functional.test;
package com.equinix.test.functional;

import java.io.File;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metro=DA
privateIpv4SubnetSize=16
vxlan=200
55 changes: 22 additions & 33 deletions equinix-openapi-metal/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15460,7 +15460,7 @@ components:
example:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
vlan: 1.4658129805029452
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
Expand Down Expand Up @@ -19070,15 +19070,10 @@ components:
type: object
VirtualNetwork:
example:
vxlan: 6
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
state: ready
vxlan: 0
metal_gateways:
- href: href
- href: href
metro_code: metro_code
instances:
- href: href
Expand Down Expand Up @@ -19115,8 +19110,12 @@ components:
items:
$ref: '#/components/schemas/Href'
type: array
metal_gateway:
$ref: '#/components/schemas/MetalGatewayLite'
metal_gateways:
description: A list of metal gateways currently associated to this Virtual
Network.
items:
$ref: '#/components/schemas/Href'
type: array
metro:
$ref: '#/components/schemas/Href'
metro_code:
Expand Down Expand Up @@ -19160,15 +19159,10 @@ components:
VirtualNetworkList:
example:
virtual_networks:
- vxlan: 6
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
state: ready
- vxlan: 0
metal_gateways:
- href: href
- href: href
metro_code: metro_code
instances:
- href: href
Expand All @@ -19183,15 +19177,10 @@ components:
assigned_to_virtual_circuit: true
assigned_to:
href: href
- vxlan: 6
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
state: ready
- vxlan: 0
metal_gateways:
- href: href
- href: href
metro_code: metro_code
instances:
- href: href
Expand Down Expand Up @@ -19478,7 +19467,7 @@ components:
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
vlan: 1.4658129805029452
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
Expand Down Expand Up @@ -19673,7 +19662,7 @@ components:
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
vlan: 1.4658129805029452
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
Expand Down Expand Up @@ -19793,7 +19782,7 @@ components:
metal_gateway:
gateway_address: gateway_address
updated_at: 2000-01-23T04:56:07.000+00:00
vlan: 0.8008281904610115
vlan: 1.4658129805029452
created_at: 2000-01-23T04:56:07.000+00:00
href: href
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
Expand Down
2 changes: 1 addition & 1 deletion equinix-openapi-metal/docs/VirtualNetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|**href** | **String** | | [optional] |
|**id** | **UUID** | | [optional] |
|**instances** | [**List&lt;Href&gt;**](Href.md) | A list of instances with ports currently associated to this Virtual Network. | [optional] |
|**metalGateway** | [**MetalGatewayLite**](MetalGatewayLite.md) | | [optional] |
|**metalGateways** | [**List&lt;Href&gt;**](Href.md) | A list of metal gateways currently associated to this Virtual Network. | [optional] |
|**metro** | [**Href**](Href.md) | | [optional] |
|**metroCode** | **String** | The Metro code of the metro in which this Virtual Network is defined. | [optional] |
|**vxlan** | **Integer** | | [optional] |
Expand Down
Loading