Skip to content
Snippets Groups Projects
Commit e60a3a7a authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Changed GCP README.md.

parent 1aeef4dd
No related branches found
No related tags found
1 merge request!23Changed GCP README.md (GONRG-848)
Pipeline #10709 failed
Copyright 2017-2020, Schlumberger
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.
# os-register-gcp
# Register Service
os-register-gcp is a [Spring Boot](https://spring.io/projects/spring-boot) service that hosts CRUD APIs that allows consumers to register a push endpoint that can be triggered when data change events happen within the OSDU R2 ecosystem.
## Running locally
## 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.
### Requirements
* Java 8
......@@ -36,33 +22,28 @@ This project uses [Lombok](https://projectlombok.org/) for code generation. You
- [Intellij configuration](https://projectlombok.org/setup/intellij)
- [VSCode configuration](https://projectlombok.org/setup/vscode)
### Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
**System Environment required to run service**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `SPRING_PROFILES_ACTIVE` | `local` | spring active profile | no ||
**System Properties required to run integration tests**
### Installation
In order to run the service locally or remotely, you will need to have the following environment variables defined.
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `DE_OPS_TESTER` | `********` | A base64 encoded google service account json credentials with _ops_ level authorization for OSDU services | yes ||
| `DE_ADMIN_TESTER` | `********` | A base64 encoded google service account json credentials with _admin_ level authorization for OSDU services | yes ||
| `DE_EDITOR_TESTER` | `********` | A base64 encoded google service account json credentials with _editor_ level authorization for OSDU services | yes ||
| `DE_NO_ACCESS_TESTER` | `********` | A base64 encoded google service account json credentials with no authorization for OSDU services | yes ||
| `LOG_PREFIX` | `service` | Logging prefix | no | - |
| `SERVER_SERVLET_CONTEXPATH` | `/api/register/v1` | Register context path | no | - |
| `ENTITLEMENTS_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment |
| `STORAGE_API` | ex `https://os-storage-dot-opendes.appspot.com/api/storage/v2` | Storage API endpoint | no | output of infrastructure deployment |
| `RECORDS_CHANGE_PUBSUB_ENDPOINT` | ex `https://os-notification-dot-opendes.appspot.com/push-handlers/records-changed` | Notification API endpoint 'records-changed' | no | output of infrastructure deployment |
| `GOOGLE_CLOUD_PROJECT` | ex `opendes` | Google Cloud Project Id | no | output of infrastructure deployment |
| `SUBSCRIBER_SECRET` | `********` | - | yes | output of infrastructure deployment |
| `SUBSCRIBER_PRIVATE_KEY_ID` | `********` | - | yes | output of infrastructure deployment |
| `INTEGRATION_TEST_AUDIENCES` | ex `*****.apps.googleusercontent.com` | Client ID for getting access to cloud resources | yes | https://console.cloud.google.com/apis/credentials |
**System Environment required to run integration tests**
**System Environment required to run service**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `ENVIRONMENT` | `local` | service running environment | no ||
### Configure Maven
| `SPRING_PROFILES_ACTIVE` | `local` | spring active profile | no |
### Run Locally
Check that maven is installed:
```bash
$ mvn --version
......@@ -73,6 +54,7 @@ Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b0
```
You will need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within `~/.m2/settings.xml`:
```bash
$ cat ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
......@@ -90,21 +72,131 @@ $ cat ~/.m2/settings.xml
</settings>
```
### Build and run the application
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*.
* 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 register service's root folder and run:
```bash
mvn jetty:run
## Testing
* Navigate to register service's root folder and run:
```bash
mvn clean install
```
* If you wish to see the coverage report then go to testing/target/site/jacoco-aggregate 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/register-gcp/ && mvn spring-boot:run -Dspring-boot.run.profiles=local
```
## Testing
Navigate to register service's root folder and run all the tests:
```bash
# build + test + install core service code
$ cd register-core/ && mvn clean install
$ (cd register-core/ && mvn clean install)
```
## Test the application
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/api/register/v1/swagger-ui.html](http://localhost:8080/api/register/v1/swagger-ui.html). If the request does not fail, you can then run the integration tests.
### Running E2E Tests
This section describes how to run cloud OSDU E2E tests (testing/register-test-gcp).
You will need to have the following environment variables defined.
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `DE_OPS_TESTER` | `********` | A base64 encoded google service account json credentials with _ops_ level authorization for OSDU services | yes | output of infrastructure deployment |
| `DE_ADMIN_TESTER` | `********` | A base64 encoded google service account json credentials with _admin_ level authorization for OSDU services | yes | output of infrastructure deployment |
| `DE_EDITOR_TESTER` | `********` | A base64 encoded google service account json credentials with _editor_ level authorization for OSDU services | yes | output of infrastructure deployment |
| `DE_NO_ACCESS_TESTER` | `********` | A base64 encoded google service account json credentials with no authorization for OSDU services | yes | output of infrastructure deployment |
| `REGISTER_BASE_URL` | ex `https://os-register-dot-opendes.appspot.com/api/register/v1` | Register API endpoint | yes | output of infrastructure deployment |
| `ENVIRONMENT` | ex `local` | 'local' for local testing or 'dev' for dev testing | no | output of infrastructure deployment |
| `SUBSCRIBER_SECRET` | ex `********` | Sensitive secret to run HMAC tests | yes | output of infrastructure deployment |
| `INTEGRATION_TEST_AUDIENCE` | ex `*****.apps.googleusercontent.com` | Client ID for getting access to cloud resources | yes | https://console.cloud.google.com/apis/credentials |
**Entitlements configuration for integration accounts**
# build + test + package gcp service code
$ cd provider/register-gcp/ && mvn clean package
| DE_OPS_TESTER | DE_ADMIN_TESTER | DE_EDITOR_TESTER | DE_NO_ACCESS_TESTER
| --- | --- | --- | --- |
| users<br/>service.entitlements.user<br/>users.datalake.ops<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{domain}.com | users<br/>service.entitlements.user<br/>users.datalake.admins<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{domain}.com | users<br/>service.entitlements.user<br/>users.datalake.editors<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{domain}.com | users<br/>service.entitlements.user<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{domain}.com
# run service
#
# Note: this assumes that the environment variables for running the service as outlined
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.
$ mvn spring-boot:run -Dspring-boot.run.profiles=local
$ (cd testing/register-test-gcp/ && mvn clean test)
```
## Deployment
* Data-Lake Register Google Cloud Endpoints on App Engine Flex environment
* Edit the app.yaml
* Open the [app.yaml](src/main/appengine/app.yaml) file in editor, and replace the YOUR-PROJECT-ID `PROJECT` line with Google Cloud Platform project Id. Also update `INTEGRATION_TEST_AUDIENCE`, `SUBSCRIBER_PRIVATE_KEY_ID`, `SPRING_PROFILES_ACTIVE`, `ENTITLEMENTS_API`, `STORAGE_API`, `RECORDS_CHANGE_PUBSUB_ENDPOINT`, `GOOGLE_CLOUD_PROJECT` and `STORAGE_API` based on your deployment
* Google Documentation: https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-appengine
#### Cloud KMS Setup
Enable cloud KMS on master project
Create king ring and key in the ***master project***
```bash
gcloud services enable cloudkms.googleapis.com
export KEYRING_NAME="csqp"
export CRYPTOKEY_NAME="registerService"
gcloud kms keyrings create $KEYRING_NAME --location global
gcloud kms keys create $CRYPTOKEY_NAME --location global \
--keyring $KEYRING_NAME \
--purpose encryption
```
### Test the application
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/api/register/v1/swagger-ui.html](http://localhost:8080/api/register/v1/swagger-ui.html). If the request does not fail, you can then run the integration tests.
\ No newline at end of file
Add **Cloud KMS CryptoKey Encrypter/Decrypter** role to the **App Engine default service account** of the master project through IAM - Role tab
Add "Cloud KMS Encrypt/Decrypt" role to the "App Engine default service account" of ***master project***
## 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment