Commit 58507d14 authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Integration Test Changes

parent 305b7403
Pipeline #9663 failed with stage
in 42 seconds
......@@ -104,25 +104,6 @@ $ (cd testing/partition-test-azure/ && mvn clean test)
A liveness check can also be performed at `http://localhost:8080/_ah/liveness_check`.
### Test the application
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/api/partition/v1/swagger-ui.html](http://localhost:8080/api/partition/v1/swagger-ui.html). If the request does not fail, you can then run the integration tests.
see [instructions](../../testing/README.md) on how to run integration tests locally. In addition to common testing environment variables, the `partition-test-azure` module also needs additional environment variables, which are described below:
```
AZURE_AD_TENANT_ID (azure tenant id)
INTEGRATION_TESTER (app-dev-sp-username)
TESTER_SERVICEPRINCIPAL_SECRET (app-dev-sp-password)
AZURE_AD_APP_RESOURCE_ID (aad-client-id)
AZURE_AD_OTHER_APP_RESOURCE_ID (AD Application ID used for negative testing)
NO_DATA_ACCESS_TESTER (aad-no-data-access-tester-client-id)
NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET (aad-no-data-access-tester-secret)
```
A liveness check can also be performed at `http://localhost:8080/api/partition/v1/_ah/liveness_check`. Other apis can be found on the swagger page
## Debugging
Jet Brains - the authors of Intellij IDEA, have written an [excellent guide](https://www.jetbrains.com/help/idea/debugging-your-first-java-application.html) on how to debug java programs.
......
......@@ -16,8 +16,10 @@ package org.opengroup.osdu.partition.api;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.opengroup.osdu.partition.util.AzureTestUtils;
@Ignore
public class TestCreatePartition extends CreatePartitionTest {
@Before
......
......@@ -16,10 +16,12 @@ package org.opengroup.osdu.partition.api;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.opengroup.osdu.partition.util.AzureTestUtils;
@Ignore
public class TestDeletePartition extends DeletePartitionTest {
@Before
@Override
public void setup() {
......
......@@ -24,7 +24,7 @@ public class AzureTestUtils extends TestUtils {
public synchronized String getAccessToken() throws Exception {
if (Strings.isNullOrEmpty(token)) {
String sp_id = System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER"));
String sp_secret = System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET"));
String sp_secret = System.getProperty("AZURE_TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("AZURE_TESTER_SERVICEPRINCIPAL_SECRET"));
String app_resource_id = System.getProperty("AZURE_AD_APP_RESOURCE_ID", System.getenv("AZURE_AD_APP_RESOURCE_ID"));
String tenant_id = System.getProperty("AZURE_AD_TENANT_ID", System.getenv("AZURE_AD_TENANT_ID"));
......@@ -44,4 +44,4 @@ public class AzureTestUtils extends TestUtils {
}
return "Bearer " + noAccessToken;
}
}
\ No newline at end of file
}
......@@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.partition.api;
import com.sun.jersey.api.client.ClientResponse;
......@@ -19,35 +18,49 @@ import org.opengroup.osdu.partition.api.descriptor.CreatePartitionDescriptor;
import org.opengroup.osdu.partition.api.descriptor.DeletePartitionDescriptor;
import org.opengroup.osdu.partition.api.descriptor.GetPartitionDescriptor;
import org.opengroup.osdu.partition.util.BaseTestTemplate;
import org.opengroup.osdu.partition.util.Config;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import static org.junit.Assert.assertEquals;
public abstract class GetPartitionByIdApitTest extends BaseTestTemplate {
private String partitionId = getIntegrationTestPrefix() + System.currentTimeMillis();
private String defaultPartition = Config.Instance().defaultPartition;
@Override
protected String getId() {
if(StringUtils.isEmpty(defaultPartition)) {
return partitionId;
} else {
return defaultPartition;
}
}
@Override
protected void deleteResource() throws Exception {
DeletePartitionDescriptor deletePartitionDes = new DeletePartitionDescriptor();
deletePartitionDes.setPartitionId(partitionId);
ClientResponse response = deletePartitionDes.run(this.getId(), this.testUtils.getAccessToken());
assertEquals(this.error(""), HttpStatus.NO_CONTENT.value(), (long) response.getStatus());
if(StringUtils.isEmpty(defaultPartition)) {
DeletePartitionDescriptor deletePartitionDes = new DeletePartitionDescriptor();
deletePartitionDes.setPartitionId(partitionId);
ClientResponse response = deletePartitionDes.run(this.getId(), this.testUtils.getAccessToken());
assertEquals(this.error(""), HttpStatus.NO_CONTENT.value(), (long) response.getStatus());
}
}
@Override
protected void createResource() throws Exception {
CreatePartitionDescriptor createPartitionDescriptor = new CreatePartitionDescriptor();
createPartitionDescriptor.setPartitionId(partitionId);
if(StringUtils.isEmpty(defaultPartition)) {
createPartitionDescriptor.setPartitionId(partitionId);
ClientResponse createResponse = createPartitionDescriptor.run(this.getId(), this.testUtils.getAccessToken());
assertEquals(this.error((String) createResponse.getEntity(String.class))
, HttpStatus.OK.value(), (long) createResponse.getStatus());
ClientResponse createResponse = createPartitionDescriptor.run(this.getId(), this.testUtils.getAccessToken());
assertEquals(this.error((String) createResponse.getEntity(String.class))
, HttpStatus.OK.value(), (long) createResponse.getStatus());
} else {
createPartitionDescriptor.setPartitionId(defaultPartition);
}
}
public GetPartitionByIdApitTest() {
......
......@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.partition.util;
public class Config {
......@@ -21,11 +20,15 @@ public class Config {
public String hostUrl;
public String osduTenant;
public String clientTenant;
public String defaultPartition;
private static Config config = new Config();
public static Config Instance() {
String env = System.getProperty("ENVIRONMENT", System.getenv("ENVIRONMENT"));
//default partition id used by integration tests to fetch info on
config.defaultPartition = System.getProperty("DEFAULT_PARTITION", System.getenv("DEFAULT_PARTITION"));
if (env == null || env.equalsIgnoreCase("LOCAL")) {
config.hostUrl = "http://localhost:8080/";
......@@ -44,3 +47,4 @@ public class Config {
return hostUrl.contains("//localhost");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment