Commit 8fe4d11c authored by Devesh's avatar Devesh
Browse files

Merge branch 'master' into pick-latest-version-of-mapping-file

parents 09e814dc e83f3901
Pipeline #44278 passed with stages
in 16 minutes and 56 seconds
......@@ -4,6 +4,14 @@ variables:
AZURE_TEST_SUBDIR: testing/wks-test-core
AZURE_DEPLOYMENTS_SUBDIR: deployments/scripts/azure
OSDU_GCP_SERVICE: wks
OSDU_GCP_VENDOR: gcp
OSDU_GCP_APPLICATION_NAME: os-wks
OSDU_GCP_WKS_MAPPING: WksMapping
OSDU_GCP_WKS_BUCKET: nice-etching-277309-wks-mapping-definitions
OSDU_GCP_ENV_VARS: GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE,AUTHORIZE_API=$OSDU_GCP_AUTHORIZE_API,GOOGLE_CLOUD_PROJECT=$OSDU_GCP_PROJECT,WKS_GCP_DATASTORE_MAPPINGINFOKIND=$OSDU_GCP_WKS_MAPPING,WKS_GCP_TENANTNAME=$TENANT_NAME,WKS_GCP_STORAGE_BUCKETNAME=$OSDU_GCP_WKS_BUCKET,PARTITION_API=$OSDU_GCP_PARTITION_API,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE
include:
- project: 'osdu/platform/ci-cd-pipelines'
ref: 'master'
......@@ -25,4 +33,12 @@ include:
ref: master
file: "cloud-providers/azure.yml"
- project: "osdu/platform/ci-cd-pipelines"
ref: master
file: 'cloud-providers/osdu-gcp-cloudrun.yml'
- local: "/devops/azure/bootstrap.yml"
osdu-gcp-test:
allow_failure: true
......@@ -12,8 +12,10 @@
<publish.releases.id>community-maven-via-job-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.releases.url>
</properties>
</profile>
......@@ -33,8 +35,10 @@
<publish.releases.id>community-maven-via-private-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.releases.url>
</properties>
</profile>
</profiles>
......@@ -63,5 +67,17 @@
</httpHeaders>
</configuration>
</server>
<server>
<id>azure-auth</id>
<configuration>
<tenant>${env.AZURE_TENANT_ID}</tenant>
<client>${env.AZURE_CLIENT_ID}</client>
<key>${env.AZURE_CLIENT_SECRET}</key>
<environment>AZURE</environment>
</configuration>
</server>
</servers>
</settings>
......@@ -7,21 +7,22 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gitlab-server>community-maven-via-job-token</gitlab-server>
<repo.releases.id>community-maven-repo</repo.releases.id>
<publish.snapshots.id>community-maven-via-job-token</publish.snapshots.id>
<publish.releases.id>community-maven-via-job-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.releases.url>
</properties>
</profile>
<profile>
<!-- This profile uses a personal token to authenticate, which is useful for local or manual runs. The
presence of the COMMUNITY_MAVEN_TOKEN variable triggers this and overrides the CI Token
based authentication -->
presence of the COMMUNITY_MAVEN_TOKEN variable triggers this and overrides the CI Token
based authentication -->
<id>GitLab-Authenticate-With-Private-Token</id>
<activation>
<property>
......@@ -29,15 +30,15 @@
</property>
</activation>
<properties>
<gitlab-server>community-maven-via-private-token</gitlab-server>
<repo.releases.id>community-maven-repo</repo.releases.id>
<publish.snapshots.id>community-maven-via-private-token</publish.snapshots.id>
<publish.releases.id>community-maven-via-private-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/157/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.releases.url>
</properties>
</profile>
</profiles>
......@@ -66,5 +67,17 @@
</httpHeaders>
</configuration>
</server>
<server>
<id>azure-auth</id>
<configuration>
<tenant>${env.AZURE_TENANT_ID}</tenant>
<client>${env.AZURE_CLIENT_ID}</client>
<key>${env.AZURE_CLIENT_SECRET}</key>
<environment>AZURE</environment>
</configuration>
</server>
</servers>
</settings>
This diff is collapsed.
......@@ -24,6 +24,10 @@ Currently the deployments folder contains a mappings folder with the required wk
The scripts/azure folder contains a deploy_mappings.py file which uploads these mappings to Azure Blob Storage.
The devops/azure/bootstrap.yaml describes the pipeline job for triggering the above python script.
## GCP implementation
Documentation for the GCP implementation is located in [here](./provider/wks-gcp/README.md).
## License
Copyright 2017-2020, Schlumberger
......
......@@ -41,11 +41,11 @@ spec:
imagePullPolicy: Always
resources:
requests:
cpu: "100m"
memory: "2Gi"
cpu: "1000m"
memory: "4Gi"
limits:
cpu: "1000m"
memory: "2Gi"
memory: "4Gi"
volumeMounts:
- name: azure-keyvault
mountPath: "/mnt/azure-keyvault"
......@@ -113,4 +113,6 @@ spec:
- name: executor_n_threads
value: "32"
- name: max_lock_renew_duration_seconds
value: "2000"
\ No newline at end of file
value: "2000"
- name: JAVA_OPTS
value: "-XX:InitialRAMPercentage=25.0 -XX:MaxRAMPercentage=50.0 -XX:+HeapDumpOnOutOfMemoryError"
\ No newline at end of file
......@@ -8,57 +8,79 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springfox-version>2.7.0</springfox-version>
<osdu.oscorecommon-version>0.7.0</osdu.oscorecommon-version>
<osdu.oscorecommon-version>0.9.0-rc13</osdu.oscorecommon-version>
</properties>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.6.RELEASE</version>
<version>2.3.10.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-wks</artifactId>
<version>0.9.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>os-wks</name>
<description>os wks service </description>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-wks</artifactId>
<version>0.9.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>os-wks</name>
<description>os wks service</description>
<modules>
<module>wks-core</module>
<module>provider/wks-gcp</module>
<module>provider/wks-azure</module>
</modules>
<modules>
<module>wks-core</module>
<module>provider/wks-gcp</module>
<module>provider/wks-azure</module>
</modules>
<repositories>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</url>
</repository>
</repositories>
<profiles>
<profile>
<id>Default</id>
<activation>
<property>
<name>!repo.releases.id</name>
</property>
</activation>
<properties>
<repo.releases.id>community-maven-repo</repo.releases.id>
<publish.snapshots.id>community-maven-via-job-token</publish.snapshots.id>
<publish.releases.id>community-maven-via-job-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven
</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/191/packages/maven
</publish.releases.url>
</properties>
</profile>
</profiles>
<distributionManagement>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/191/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/191/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>${repo.releases.id}</id>
<url>${repo.releases.url}</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>${publish.releases.id}</id>
<url>${publish.releases.url}</url>
</repository>
<snapshotRepository>
<id>${publish.snapshots.id}</id>
<url>${publish.snapshots.url}</url>
</snapshotRepository>
</distributionManagement>
</project>
......@@ -12,9 +12,10 @@
<description>WKS service on Azure</description>
<packaging>jar</packaging>
<properties>
<osdu.corelibazure.version>0.7.0</osdu.corelibazure.version>
<osdu.corelibazure.version>0.9.0-rc5</osdu.corelibazure.version>
<azure.applicationinsights.version>2.6.1</azure.applicationinsights.version>
<osdu.os-wks-core.version>0.9.0-SNAPSHOT</osdu.os-wks-core.version>
<azure.version>2.1.7</azure.version>
</properties>
<dependencyManagement>
<dependencies>
......@@ -32,6 +33,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
<version>${azure.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
......@@ -96,25 +98,18 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-cbor</artifactId>
<version>2.12.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/44/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/44/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
......
package org.opengroup.osdu.wks.provider.azure.util;
package org.opengroup.osdu.wks.provider.azure.utils;
import static org.hamcrest.CoreMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.ArgumentMatchers.any;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.wks.provider.azure.utils.AppInsightsMetric;
......@@ -23,7 +18,7 @@ public class AppInsightsMetricTest {
@Mock
TelemetryClient mockTelemetryClient;
@Before()
@BeforeEach()
public void setUp() throws Exception {
mockTelemetryClient = mock(TelemetryClient.class);
......
# wks-gcp
The WKS Service is a Maven multi-module project with each cloud implementation placed in its submodule. WKS service listen to records_change event of Storage Service.
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
### Prerequisites
Pre-requisites
* GCloud SDK with java (latest version)
* JDK 8
* Lombok 1.16 or later
* Maven
### Installation
In order to run the service locally, you will need to have the following environment variables defined.
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `GOOGLE_AUDIENCES` | ex `*****.apps.googleusercontent.com` | Client ID for getting access to cloud resources | yes | https://console.cloud.google.com/apis/credentials |
| `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | https://console.cloud.google.com/iam-admin/serviceaccounts |
| `AUTHORIZE_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | yes | output of infrastructure deployment |
| `GOOGLE_CLOUD_PROJECT` | ex `osdu-cicd-epam` | Google Cloud Project Id | yes | - |
| `wks.gcp.datastore-mappingInfoKind` | WksMapping | kind for Datastore | yes | - |
| `wks.gcp.tenantName` | ex `opendes` | Tenant name | yes | - |
| `wks.gcp.storage-bucketName` | ex `osdu-cicd-epam-wks-mapping-definitions` | Storage bucket name for mapping definitions | yes | - |
### Run Locally
Check that maven is installed:
```bash
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b04/jre
...
```
You may need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within `~/.mvn/community-maven.settings.xml`:
```bash
$ cat ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>community-maven-via-private-token</id>
<!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
<!-- The generated token expires on or before 11/14/2019 -->
<configuration>
<httpHeaders>
<property>
<name>Private-Token</name>
<value>${env.COMMUNITY_MAVEN_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
```
* Update the Google cloud SDK to the latest version:
```bash
gcloud components update
```
* Set Google Project Id:
```bash
gcloud config set project <YOUR-PROJECT-ID>
```
* Perform a basic authentication in the selected project:
```bash
gcloud auth application-default login
```
* Navigate to wks service's root folder and run:
```bash
mvn clean install
```
* If you wish to see the coverage report then go to target\site\jacoco\index.html and open index.html
* If you wish to build the project without running tests
```bash
mvn clean install -DskipTests
```
After configuring your environment as specified above, you can follow these steps to build and run the application. These steps should be invoked from the *repository root.*
```bash
cd provider/wks-gcp/ && mvn spring-boot:run
```
## Testing
### Running E2E Tests
This section describes how to run cloud OSDU E2E tests (testing/wks-test-core).
You will need to have the following environment variables defined.
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `DOMAIN` | ex `contoso.com` | OSDU R2 to run tests under | no | - |
| `INTEGRATION_TESTER` | `********` | Service account for API calls, as a filename or JSON content, plain or Base64 encoded. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts |
| `LEGAL_TAG` | `********` | Demo legal tag used to pass test| yes | Legal service |
| `VENDOR` | ex `gcp`| vendor name | yes | - |
| `INTEGRATION_TEST_AUDIENCE` | `********`| client application ID | yes | https://console.cloud.google.com/apis/credentials |
| `TENANT_NAME` | ex `opendes`| OSDU tenant used for testing | yes | - |
| `ACL_VIEWERS` | ex `data.test1`| acl viewers | yes | - |
| `ACL_OWNERS` | ex `data.test1`| acl owners | yes | - |
| `DATA_PARTITION_ID` | ex `opendes`| data partition ID | yes | - |
| `STORAGE_URL` | ex `********/api/storage/v2/`| storage service URL | yes | - |
| `HOST` | `` | schema service URL | yes | - |
Execute following command to build code and run all the integration tests:
```bash
# Note: this assumes that the environment variables for integration tests as outlined
# above are already exported in your environment.
$ (cd testing/wks-test-core/ && mvn clean test)
```
## Deployment
WKS Service is compatible with App Engine Flexible Environment and Cloud Run.
* To deploy into Cloud run, please, use this documentation:
https://cloud.google.com/run/docs/quickstarts/build-and-deploy
* To deploy into App Engine, please, use this documentation:
https://cloud.google.com/appengine/docs/flexible/java/quickstart
## Licence
Copyright © Google LLC
Copyright © EPAM Systems
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
\ No newline at end of file
# Use the official AdoptOpenJDK for a base image.
# https://hub.docker.com/_/openjdk
FROM openjdk:8-slim
WORKDIR /app
ARG PROVIDER_NAME
ENV PROVIDER_NAME $PROVIDER_NAME
ARG PORT
ENV PORT $PORT
# Copy the jar to the production image from the builder stage.
COPY provider/wks-${PROVIDER_NAME}/target/os-wks-${PROVIDER_NAME}-*-boot.jar wks-${PROVIDER_NAME}.jar
# Run the web service on container startup.
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -jar /app/wks-${PROVIDER_NAME}.jar
# Copyright 2020 Google LLC
# Copyright 2017-2019, Schlumberger
# Copyright 2020 EPAM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'--build-arg', 'PROVIDER_NAME=${_PROVIDER_NAME}',
'--build-arg', 'PORT=${_PORT}',
'-t', 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}:${_SHORT_SHA}',
'-t', 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}:latest',
'-f', 'provider/wks-${_PROVIDER_NAME}/cloudbuild/Dockerfile.cloudbuild',
'.'
]
images:
- 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}'
......@@ -4,7 +4,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-wks</artifactId>
<version>0.9.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>os-wks-gcp</artifactId>
<description>Google cloud related implementation stuff.</description>
......@@ -19,17 +19,17 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.0.11</version>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.17</version>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.105.0</version>
<version>1.108.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
......@@ -54,12 +54,6 @@
<version>v1-rev310-1.25.0</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.15</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
......@@ -87,27 +81,13 @@
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>