Skip to content

Commit

Permalink
introduced new structured, adjusted running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkat committed Sep 13, 2024
1 parent a8bfd4a commit 5f8d4ca
Show file tree
Hide file tree
Showing 72 changed files with 2,036 additions and 3,840 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ jobs:
- name: Tests
shell: bash
run: |-
cd equinix-openapi-fabric
mvn clean test -DenvUrl=${{ env.TEST_HOST_URL }}
- name: Generate report
if: always()
shell: bash
run: |-
cd equinix-openapi-fabric
cd equinix-openapi-fabric-tests
mvn surefire-report:report -DskipTests
ls
find .
- name: attach report as attachment
if: always()
uses: actions/upload-artifact@v4
with:
name: test report
path: ./equinix-openapi-fabric/target/reports
path: ./equinix-openapi-fabric-tests/target/reports
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ hs_err_pid*
# JetBrains project directory files
*.idea
*.idea/
equinix-openapi-fabric/target
equinix-openapi-fabric-tests/target
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ docker_generate:
--git-user-id ${GIT_ORG}

build_client:
rm -rf ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH}v4; cp -r v4 ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH}
rm -rf ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH}v4;
16 changes: 16 additions & 0 deletions equinix-openapi-fabric-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# equinix-openapi-fabric-tests

## Requirements

Building the API client library requires:

1. Java 1.8+
2. Maven (3.8.3+)

## Installation

To install the API client library to your local Maven repository, simply execute:

```shell
mvn clean install
```
8 changes: 8 additions & 0 deletions equinix-openapi-fabric-tests/equinix-openapi-fabric-tests.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$" dumb="true">
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
</content>
</component>
</module>
42 changes: 42 additions & 0 deletions equinix-openapi-fabric-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.equinix</groupId>
<artifactId>openapi-fabric-tests</artifactId>
<name>equinix-openapi-fabric-tests</name>
<version>0.5.0</version>

<parent>
<groupId>com.equinix</groupId>
<artifactId>equinix-openapi-fabric-core</artifactId>
<version>0.0.1</version>
</parent>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<includes>
<include>**Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>com.equinix</groupId>
<artifactId>equinix-openapi-fabric</artifactId>
<version>0.5.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem;
import com.equinix.openapi.fabric.v4.api.helpers.Utils;
import com.equinix.openapi.fabric.tests.dto.users.UsersItem;
import com.equinix.openapi.fabric.tests.helpers.Utils;
import com.equinix.openapi.fabric.v4.model.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.UUID;

import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*;
import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users;
import static com.equinix.openapi.fabric.tests.helpers.Apis.*;
import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;

/**
* API tests for CloudRoutersApi
Expand All @@ -40,12 +40,12 @@ public static void removeCloudRouters(UsersItem.UserName userName) {
});
}

@BeforeAll
@BeforeClass
public static void setUp() {
setUserName(userName);
}

@AfterAll
@AfterClass
public static void removeResources() {
removeCloudRouters(userName);
}
Expand Down Expand Up @@ -273,7 +273,6 @@ private static void waitForCloudRouterIsProvisioned(UUID cloudRouterUuid) {
}
}

assertTrue(result,
"Cloud Router has not reached the expected state: " + CloudRouterAccessPointState.PROVISIONED + " current state: " + currentState.getValue());
assertTrue("Cloud Router has not reached the expected state: " + CloudRouterAccessPointState.PROVISIONED + " current state: " + currentState.getValue(), result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.api.dto.port.PortDto;
import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem;
import com.equinix.openapi.fabric.v4.api.helpers.Utils;
import com.equinix.openapi.fabric.tests.dto.port.PortDto;
import com.equinix.openapi.fabric.tests.dto.users.UsersItem;
import com.equinix.openapi.fabric.tests.helpers.Utils;
import com.equinix.openapi.fabric.v4.model.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.stream.Collectors;

import static com.equinix.openapi.fabric.v4.api.CloudRoutersApiTest.createRouter;
import static com.equinix.openapi.fabric.v4.api.PortsApiTest.getPorts;
import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*;
import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users;
import static com.equinix.openapi.fabric.v4.api.helpers.Utils.getRandomVlanNumber;
import static com.equinix.openapi.fabric.tests.CloudRoutersApiTest.createRouter;
import static com.equinix.openapi.fabric.tests.PortsApiTest.getPorts;
import static com.equinix.openapi.fabric.tests.helpers.Apis.*;
import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users;
import static com.equinix.openapi.fabric.tests.helpers.Utils.getRandomVlanNumber;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertEquals;

public class ConnectionsApiTest {
private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR;
Expand All @@ -50,12 +50,12 @@ public static void removeConnections(UsersItem.UserName userName) {
});
}

@BeforeAll
@BeforeClass
public static void setUp() {
setUserName(userName);
}

@AfterAll
@AfterClass
public static void removeResources() {
removeConnections(userName);
CloudRoutersApiTest.removeCloudRouters(userName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.model.Metro;
import com.equinix.openapi.fabric.v4.model.MetroResponse;
import com.equinix.openapi.fabric.v4.model.Presence;
import org.junit.jupiter.api.Test;
import org.junit.Test;

import static com.equinix.openapi.fabric.v4.api.helpers.Apis.metrosApi;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static com.equinix.openapi.fabric.tests.helpers.Apis.metrosApi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* API tests for MetrosApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem;
import com.equinix.openapi.fabric.v4.api.helpers.Utils;
import com.equinix.openapi.fabric.tests.dto.users.UsersItem;
import com.equinix.openapi.fabric.tests.helpers.Utils;
import com.equinix.openapi.fabric.v4.model.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.UUID;

import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users;
import static com.equinix.openapi.fabric.v4.api.helpers.Apis.networksApi;
import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName;
import static com.equinix.openapi.fabric.tests.helpers.Apis.networksApi;
import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName;
import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

/**
* API tests for NetworksApi
*/
class NetworksApiTest {
public class NetworksApiTest {
private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FNV;

public static void removeNetworks(UsersItem.UserName userName) {
users.get(userName).getUserResources().getNetworksUuid().forEach(com.equinix.openapi.fabric.v4.api.NetworksApiTest::deleteNetwork);
users.get(userName).getUserResources().getNetworksUuid().forEach(NetworksApiTest::deleteNetwork);
}

@BeforeAll
@BeforeClass
public static void setUp() {
setUserName(userName);
}

@AfterAll
@AfterClass
public static void removeResources() {
removeNetworks(userName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.api.dto.port.PortDto;
import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem;
import com.equinix.openapi.fabric.v4.api.helpers.Utils;
import com.equinix.openapi.fabric.tests.dto.port.PortDto;
import com.equinix.openapi.fabric.tests.dto.users.UsersItem;
import com.equinix.openapi.fabric.tests.helpers.Utils;
import com.equinix.openapi.fabric.v4.model.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.List;

import static com.equinix.openapi.fabric.v4.api.helpers.Apis.portsApi;
import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName;
import static com.equinix.openapi.fabric.tests.helpers.Apis.portsApi;
import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* API tests for PortsApi
*/
public class PortsApiTest {
private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR;

@BeforeAll
@BeforeClass
public static void setUp() {
setUserName(userName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@
* Do not edit the class manually.
*/

package com.equinix.openapi.fabric.v4.api;
package com.equinix.openapi.fabric.tests;

import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem;
import com.equinix.openapi.fabric.v4.model.FilterBody;
import com.equinix.openapi.fabric.v4.model.PriceSearchResponse;
import com.equinix.openapi.fabric.v4.model.SearchExpression;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.equinix.openapi.fabric.tests.dto.users.UsersItem;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;

import static com.equinix.openapi.fabric.v4.api.helpers.Apis.pricesApi;
import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static com.equinix.openapi.fabric.tests.helpers.Apis.pricesApi;
import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

/**
* API tests for PricesApi
*/
public class PricesApiTest {

@BeforeAll
@BeforeClass
public static void setUp() {
setUserName(UsersItem.UserName.PANTHERS_FCR);
}
Expand Down
Loading

0 comments on commit 5f8d4ca

Please sign in to comment.