Skip to content
Snippets Groups Projects
README.md 7.08 KiB
Newer Older
  • Learn to ignore specific revisions
  • ## Running Locally
    
    ### Requirements
    
    In order to run this service locally, you will need the following:
    
    - [Maven 3.6.0+](https://maven.apache.org/download.cgi)
    - [AdoptOpenJDK8](https://adoptopenjdk.net/)
    - Infrastructure dependencies, deployable through the relevant [infrastructure template](https://dev.azure.com/slb-des-ext-collaboration/open-data-ecosystem/_git/infrastructure-templates?path=%2Finfra&version=GBmaster&_a=contents)
    - While not a strict dependency, example commands in this document use [bash](https://www.gnu.org/software/bash/)
    
    ### General Tips
    
    **Environment Variable Management**
    The following tools make environment variable configuration simpler
     - [direnv](https://direnv.net/) - for a shell/terminal environment
     - [EnvFile](https://plugins.jetbrains.com/plugin/7861-envfile) - for [Intellij IDEA](https://www.jetbrains.com/idea/)
    
    **Lombok**
    This project uses [Lombok](https://projectlombok.org/) for code generation. You may need to configure your IDE to take advantage of this tool.
     - [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.
    
    **Note** The following command can be useful to pull secrets from keyvault:
    ```bash
    az keyvault secret show --vault-name $KEY_VAULT_NAME --name $KEY_VAULT_SECRET_NAME --query value -otsv
    ```
    
    **Required to run service**
    
    | name | value | description | sensitive? | source |
    | ---  | ---   | ---         | ---        | ---    |
    
    | `AZURE_TENANT_ID` | `********` | AAD tenant ID | yes | output of infrastructure deployment |
    | `AZURE_CLIENT_ID` | `********` | AAD client ID | yes | output of infrastructure deployment |
    | `AZURE_CLIENT_SECRET` | `********` | AAD client secret | yes | output of infrastructure deployment |
    | `aad_client_id` | `********` | AAD client application ID | yes | output of infrastructure deployment |
    
    | `KEYVAULT_URI` | ex `https://foo-keyvault.vault.azure.net/` | URI of KeyVault that holds application secrets | no | output of infrastructure deployment |
    
    | `appinsights_key` | `********` | API Key for App Insights | yes | output of infrastructure deployment |
    | `cosmosdb_database`| ex OSDU-foo |Cosmos db name having subscriptions| no | output of infrastructure deployment |
    | `LOG_PREFIX` | `notification` | Logging prefix | no | - |
    | `entitlements_service_endpoint` | ex `https://foo-entitlements.azurewebsites.net` | Entitlements API endpoint | no | output of infrastructure deployment |
    | `registeration_service_endpoint`| ex `https://foo-register.azurewebsites.net`| Registration Service API endpoint | no | output of infrastructure deployment |
    | `partition_service_endpoint` |  ex `https://foo-partition.azurewebsites.net` | Partition Service API endpoint | no | output of infrastructure deployment |
    | `server_port`| 8089 | Port to host service locally | no | application-specific |
    | `maxCacheSize` | 200| cache size | no | application-specific |
    | `spring_application_name` | notification-azure| application name | no | - |
    | `executor_n_threads` | 15| no of executor threads running at a time | no | application-specific |
    | `max_concurrent_calls` | 15| max concurrent calls | no | application-specific |
    | `max_lock_renew_duration_seconds` | 15| max lock duration before time out of a message | no | application-specific |
    | `initial_subscription_manager_delay_seconds` | 0| delay in first listening of new subscriptions | no | application-specific |
    | `consecutive_subscription_manager_delay_seconds` | 0| delay in consecutive listening of new subscriptions | no | application-specific |
    | `service_bus_enabled` | true| feature flag for notification V2 | no | application-specific |
    | `event_grid_to_service_bus_enabled` | false| will be deprecated | no | application-specific |
    | `event_grid_enabled` | false| feature flag for notification V1| no | application-specific |
    | `azure_entitlements_factory_enabled` | false| set to false | no | application-specific |
    
    
    
    ### Configure Maven
    
    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 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"?>
    <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>os-core</id>
                <username>mvn-pat</username>
                <!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
                <password>$PERSONAL_ACCESS_TOKEN_GOES_HERE</password>
            </server>
        </servers>
    </settings>
    ```
    
    ### Build and run the application
    
    After configuring your environment as specified above, you can follow these steps to build and run the application.
    1. Navigate to the root of the schema project, os-schema. For building the project using command line, run below command :
        ```bash
        mvn clean install
        ```
        This will build the core project as well as all the underlying projects. If we want  to build projects for specific cloud vendor, we can use mvn --projects command. For example, if we want to build only for Azure, we can use below command :
        ```bash
        mvn --projects notification-core,provider/notification-azure clean install
        ```
    2. Run schema service in command line. We need to select which cloud vendor specific schema-service we want to run. For example, if we want to run schema-service for Azure, run the below command : 
        ```bash 
        # Running Azure : 
        java -jar  provider\schema-azure\target\os-notification-azure-0.0.1-SNAPSHOT-spring-boot.jar
    3. The port and path for the service endpoint can be configured in ```application.properties``` in the provider folder as following. If not specified, then  the web container (ex. Tomcat) default is used: 
        ```bash
        server.servlet.contextPath=/api/notification/v1/
        server.port=8080
        ```
    
    ## 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.
    
    
    ## Deploying service 
    
    TBD
    
    ## License
    Copyright © Microsoft Corporation
    
    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.