Newer
Older
Igor Filippov (EPAM)
committed
# legal-gcp
Igor Filippov (EPAM)
committed
os-legal-gcp is a Spring Boot service that hosts CRUD APIs that enable management of legal tags within the OSDU R2 ecosystem.
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
## Getting Started
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
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
Igor Filippov (EPAM)
committed
- [Maven 3.6.0+](https://maven.apache.org/download.cgi)
- [AdoptOpenJDK8](https://adoptopenjdk.net/)
Igor Filippov (EPAM)
committed
- [Lombok 1.16 or later](https://projectlombok.org/setup/maven)
- [GCloud SDK with java (latest version)](https://cloud.google.com/sdk/docs/install)
### Installation
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
- Setup Apache Maven
- Setup AdoptOpenJDK
- Setup GCloud SDK
- Install Eclipse (or other IDE) to run applications
- Set up environment variables for Apache Maven and AdoptOpenJDK. For example M2_HOME, JAVA_HOME, etc.
- Add a configuration for build project in Eclipse(or other IDE)
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
### Run Locally
Igor Filippov (EPAM)
committed
Check that maven is installed:
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
```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`:
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
```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>
```
Igor Filippov (EPAM)
committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
* 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 search service's root folder and run:
```bash
mvn jetty:run
## Testing
* Navigate to legal 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
```
Igor Filippov (EPAM)
committed
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.*
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
```bash
cd provider/legal-gcp/ && mvn spring-boot:run
```
Igor Filippov (EPAM)
committed
## Testing
Navigate to legal service's root folder and run all the tests:
Igor Filippov (EPAM)
committed
```bash
# build + install integration test core
$ (cd testing/legal-test-core/ && mvn clean install)
Igor Filippov (EPAM)
committed
```
### Running E2E Tests
This section describes how to run cloud OSDU E2E tests (testing/legal-test-gcp).
You will need to have the following environment variables defined.
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `GCLOUD_PROJECT` | `nice-etching-277309` | google cloud project ID | yes | - |
| `MY_TENANT_PROJECT` | `osdu` | my tenant project name | yes | - |
| `INTEGRATION_TEST_AUDIENCE` | `********` | client application ID | yes | https://console.cloud.google.com/apis/credentials |
| `INTEGRATION_TESTER` | `********` | Service account for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts |
| `HOST_URL` | `http://localhsot:8080/api/legal/v1/` | - | yes | - |
| `MY_TENANT` | `osdu` | OSDU tenant used for testing | yes | - |
| `SKIP_HTTP_TESTS` | ex `true` | jetty server returns 403 when running locally when deployed jettyserver is not used and the app returns a 302 so just run against deployed version only when checking http -> https redirects. Use 'true' for Google Cloud Run | yes | - |
| `GOOGLE_AUDIENCES` | ex `*****.apps.googleusercontent.com` | Client ID for getting access to cloud resources | yes | https://console.cloud.google.com/apis/credentials |
| `PARTITION_API` | ex `http://localhost:8081/api/partition/v1` | Partition service endpoint | no | - |
Igor Filippov (EPAM)
committed
**Entitlements configuration for integration accounts**
Igor Filippov (EPAM)
committed
Igor Filippov (EPAM)
committed
| INTEGRATION_TESTER |
| --- |
| users<br/>service.entitlements.user<br/>service.legal.admin<br/>service.legal.editor<br/>service.legal.user<br/>data.test1<br/>data.integration.test |
Execute following command to build code and run all the integration tests:
```bash
Igor Filippov (EPAM)
committed
# Note: this assumes that the environment variables for integration tests as outlined
# above are already exported in your environment.
$ (cd testing/legal-test-core/ && mvn clean install)
Igor Filippov (EPAM)
committed
$ (cd testing/legal-test-gcp/ && mvn clean test)
```
Igor Filippov (EPAM)
committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
## Deployment
* Data-Lake Legal Google Cloud Endpoints on App Engine Flex environment
* Deploy
```sh
mvn appengine:deploy -pl org.opengroup.osdu.legal:legal -amd
```
* If you wish to deploy the search service without running tests
```sh
mvn appengine:deploy -pl org.opengroup.osdu.legal:legal -amd -DskipTests
```
or
* Google Documentation: https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-appengine
## 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.