Commit 34dfa200 authored by Aman Verma's avatar Aman Verma
Browse files

fixing merge conflict

parents 004c24b1 c8fffa36
Pipeline #11012 failed with stage
in 7 seconds
......@@ -22,6 +22,14 @@ variables:
AWS_ENVIRONMENT: dev
AWS_MAVEN_TEST_COMMAND_OVERRIDE: verify
OSDU_GCP_SERVICE: schema
OSDU_GCP_VENDOR: gcp
OSDU_GCP_APPLICATION_NAME: os-schema
OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_URL,AUTHORIZE_API_KEY=$OSDU_GCP_AUTHORIZE_API_KEY,LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG,ACCOUNT_ID_COMMON_PROJECT=$TENANT --vpc-connector=$OSDU_GCP_VPC_CONNECTOR
include:
- project: "osdu/platform/ci-cd-pipelines"
file: "standard-setup.yml"
......@@ -46,3 +54,19 @@ include:
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/azure.yml"
- project: "osdu/platform/ci-cd-pipelines"
ref: 'master'
file: 'cloud-providers/osdu-gcp-cloudrun.yml'
osdu-gcp-test:
image: maven:3.3.9-jdk-8
extends:
- .osdu-gcp-variables
stage: integration
needs: ["osdu-gcp-deploy"]
script:
- echo 'GCP integrations tests - TBD'
only:
variables:
- $OSDU_GCP == 'true'
This diff is collapsed.
......@@ -62,11 +62,11 @@ Below command has to be run post building complete project.
cd testing/schema-test-core
mvn verify -DVENDOR=gcp -DHOST=https://open.opendes.cloud.slb-ds.com -DPRIVATE_TENANT1=opendes -DPRIVATE_TENANT2=tenant2 -DSHARED_TENANT=common -Dcucumber.options="--tags @SchemaService"
mvn verify -DVENDOR=gcp -DHOST=https://open.opendes.cloud.slb-ds.com -DPRIVATE_TENANT1=opendes -DPRIVATE_TENANT2=tenant2 -DSHARED_TENANT=common
Below command can be run through azure-pipeline.yml after setting environment variables in the pipeline.
verify "-Dcucumber.options=--tags @SchemaService"
verify
## Deploy Shared Schemas
Schema service as part of deployment deploys pre-defined OSDU schemas so end users can get community accepted schemas to refer. Such schemas are present in [folder](https://dev.azure.com/slb-des-ext-collaboration/open-data-ecosystem/_git/os-schema?path=%2Fdeployments%2Fshared-schemas%2Fosdu) and script to deploy the schema are present [here](https://dev.azure.com/slb-des-ext-collaboration/open-data-ecosystem/_git/os-schema?path=%2Fdeployments%2Fscripts).
......
......@@ -92,7 +92,7 @@ stages:
displayName: 'Running IntegrationTest'
inputs:
mavenPomFile: 'testing/schema-test-core/pom.xml'
goals: 'verify "-Dcucumber.options=--tags @SchemaService"'
goals: 'verify'
options: '--settings maven/settings.xml -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN)'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
......
......@@ -44,6 +44,7 @@
<module>provider/schema-gcp</module>
<module>provider/schema-ibm</module>
<module>provider/schema-azure</module>
<module>testing/schema-test-core</module>
</modules>
<repositories>
<repository>
......@@ -62,4 +63,5 @@
<url>https://community.opengroup.org/api/v4/projects/26/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
......@@ -131,4 +131,4 @@
</distributionManagement>
</project>
\ No newline at end of file
</project>
# Use the official AdoptOpenJDK for a base image.
# https://hub.docker.com/_/openjdk
FROM openjdk:8-slim
WORKDIR /app
ARG PORT
ENV PORT $PORT
# Copy the jar to the production image from the builder stage.
COPY provider/schema-gcp/target/os-schema-gcp-*-spring-boot.jar schema.jar
# Run the web service on container startup.
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -jar /app/schema.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', 'PORT=${_PORT}',
'-t', 'gcr.io/$PROJECT_ID/os-schema/schema-gcp:${_SHORT_SHA}',
'-t', 'gcr.io/$PROJECT_ID/os-schema/schema-gcp:latest',
'-f', 'provider/schema-gcp/cloudbuild/Dockerfile.cloudbuild',
'.'
]
images:
- 'gcr.io/$PROJECT_ID/os-schema/schema-gcp'
......@@ -17,7 +17,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.105.0</version>
<version>1.108.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-datastore -->
......@@ -112,23 +112,4 @@
</plugins>
</build>
<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/26/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/26/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
\ No newline at end of file
</project>
service: os-schema
runtime: java
env: flex
resources:
cpu: 2
memory_gb: 6
automatic_scaling:
min_num_instances: 2
max_num_instances: 5
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7
env_variables:
SPRING_PROFILES_ACTIVE: 'ENVIRONMENT'
......@@ -27,6 +27,7 @@ import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore;
import org.opengroup.osdu.schema.util.VersionHierarchyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import com.google.cloud.Timestamp;
......@@ -65,6 +66,9 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
@Autowired
JaxRsDpsLog log;
@Value("${account.id.common.project}")
private String commonAccountId;
/**
* Method to get schemaInfo from google store
*
......@@ -305,11 +309,11 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
public boolean isUnique(String schemaId, String tenantId) throws ApplicationException {
Set<String> tenantList = new HashSet<>();
tenantList.add(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT);
tenantList.add(commonAccountId);
tenantList.add(tenantId);
// code to call check uniqueness
if (tenantId.equalsIgnoreCase(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT)) {
if (tenantId.equalsIgnoreCase(commonAccountId)) {
List<String> privateTenantList = tenantFactory.listTenantInfo().stream().map(TenantInfo::getDataPartitionId)
.collect(Collectors.toList());
tenantList.addAll(privateTenantList);
......@@ -328,4 +332,12 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
}
return true;
}
public String getCommonAccountId() {
return commonAccountId;
}
public void setCommonAccountId(String commonAccountId) {
this.commonAccountId = commonAccountId;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.NotFoundException;
import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import com.google.cloud.storage.Blob;
......
......@@ -7,3 +7,4 @@ management.health.elasticsearch.enabled=false
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=health
LOG_PREFIX=schema
account.id.common.project=common
......@@ -172,6 +172,7 @@ public class GoogleSchemaInfoStoreTest {
KeyFactory storageKeyFactory = mock(KeyFactory.class);
String schemaId = "schemaId";
String tenantId = "tenant";
schemaInfoStore.setCommonAccountId(tenantId);
Mockito.when(tenantFactory.getTenantInfo("tenant")).thenReturn(tenantInfo);
Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon);
Mockito.when(tenantInfo.getName()).thenReturn("tenant");
......
......@@ -121,4 +121,4 @@
</build>
</project>
\ No newline at end of file
</project>
......@@ -203,4 +203,4 @@
</plugins>
</build>
</project>
\ No newline at end of file
</project>
package org.opengroup.osdu.schema.api;
import javax.validation.Valid;
import org.opengroup.osdu.schema.constants.SchemaConstants;
import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.BadRequestException;
import org.opengroup.osdu.schema.exceptions.NoSchemaFoundException;
import org.opengroup.osdu.schema.exceptions.NotFoundException;
import org.opengroup.osdu.schema.model.QueryParams;
import org.opengroup.osdu.schema.model.SchemaInfo;
import org.opengroup.osdu.schema.model.SchemaInfoResponse;
import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.model.SchemaUpsertResponse;
import org.opengroup.osdu.schema.service.ISchemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -73,13 +72,8 @@ public class SchemaController {
public ResponseEntity<SchemaInfo> upsertSchema(@Valid @RequestBody SchemaRequest schemaRequest)
throws ApplicationException, BadRequestException {
ResponseEntity<SchemaInfo> response = null;
try {
response = new ResponseEntity<>(schemaService.updateSchema(schemaRequest), HttpStatus.OK);
} catch (NoSchemaFoundException noSchemaFound) {
response = new ResponseEntity<>(schemaService.createSchema(schemaRequest), HttpStatus.CREATED);
}
SchemaUpsertResponse upsertResp = schemaService.upsertSchema(schemaRequest);
ResponseEntity<SchemaInfo> response = new ResponseEntity<>(upsertResp.getSchemaInfo(), upsertResp.getHttpCode());
return response;
}
......
......@@ -99,6 +99,7 @@ public class SchemaConstants {
public static final String BAD_INPUT = "Bad input parameter";
public static final String INVALID_AUTHORIZATION_TOKEN = "Invalid authorization token";
public static final String SCHEMA_ID_EXISTS = "Schema Id is already present";
public static final String INVALID_UPDATE_OPERATION = "Update/Create failed because schema id is present in another tenant";
public static final String UNAUTHORIZED_EXCEPTION = "User is unauthorized to perform this action";
// OSDU
......
package org.opengroup.osdu.schema.model;
import org.springframework.http.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SchemaUpsertResponse {
SchemaInfo schemaInfo;
HttpStatus httpCode;
}
......@@ -7,6 +7,7 @@ import org.opengroup.osdu.schema.model.QueryParams;
import org.opengroup.osdu.schema.model.SchemaInfo;
import org.opengroup.osdu.schema.model.SchemaInfoResponse;
import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.model.SchemaUpsertResponse;
public interface ISchemaService {
......@@ -15,7 +16,18 @@ public interface ISchemaService {
SchemaInfo createSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
SchemaInfo updateSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
/**
* This method first tries to update the schema with the given schema-id. If there is no schema found,
* it tries to create the new schema for the given tenant.
*
* @param schemarequest
* @return SchemaUpsertResponse
* @throws ApplicationException
* @throws BadRequestException
*/
SchemaUpsertResponse upsertSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
SchemaInfoResponse getSchemaInfoList(QueryParams queryParams) throws BadRequestException, ApplicationException;
}
Supports Markdown
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