Commit b5c7ee66 authored by Anastasiia Gelmut's avatar Anastasiia Gelmut Committed by Rostislav Dublin (EPAM)
Browse files

Added service version endpoint (GONRG-2887)

parent 47e94dea
This diff is collapsed.
......@@ -368,3 +368,5 @@ Remember to set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Follo
on the Google developer's portal][application-default-credentials].
* Documentation for the GCP Cloud Datastore implementation is located in [here](./provider/workflow-gcp/README.md)
......@@ -36,5 +36,6 @@ spec:
"/api/workflow/swagger-resources/*",
"/api/workflow/webjars/*",
"/api/workflow/swagger-ui/*",
"*/v3/api-docs"
"*/v3/api-docs",
"/api/workflow/info"
]
......@@ -493,6 +493,21 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/error'
/info:
get:
tags:
- info
summary: "Version info"
description: "For deployment available public `/info` endpoint, \
\ which provides build and git related information."
operationId: "Version info"
responses:
"200":
description: "Version info."
content:
application/json:
schema:
$ref: "#/components/schemas/VersionInfo"
components:
......@@ -619,3 +634,44 @@ components:
type: string
reason:
type: string
VersionInfo:
type: "object"
properties:
groupId:
type: "string"
description: "Maven artifact group ID."
actifactId:
type: "string"
description: "Maven artifact ID."
version:
type: "string"
description: "Maven artifact version"
buildTime:
type: "string"
description: "Maven artifact build time"
branch:
type: "string"
description: "Current git branch"
commitId:
type: "string"
description: "Latest commit hash"
commitMessage:
type: "string"
description: "Latest commit message"
connectedOuterServices:
type: "array"
description: "Connected outer services information"
items:
$ref: "#/components/schemas/ConnectedOuterService"
description: "Version info."
ConnectedOuterService:
type: "object"
properties:
name:
type: "string"
description: "Connected outer service name."
version:
type: "string"
description: "Connected outer service version."
description: "Connected outer service information."
......@@ -49,7 +49,7 @@
<javax.inject.version>1</javax.inject.version>
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
<os-core-common.version>0.10.0</os-core-common.version>
<os-core-common.version>0.11.0-rc4</os-core-common.version>
<springfox.version>3.0.0</springfox.version>
</properties>
......@@ -214,6 +214,18 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
......@@ -289,6 +301,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.5</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -27,4 +27,4 @@ osdu.entitlements.url= ${OSDU_ENTITLEMENTS_URL}
google.audiences=123.apps.googleusercontent.com
partition.api=http://localhost:8081/api/partition/v1
osdu.version.info.gitPropertiesPath=/git.properties
......@@ -28,6 +28,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/configuration/security",
"/swagger-ui.html",
"/swagger",
"/info",
"/webjars/**",
"/liveness_check",
"/readiness_check").permitAll()
......
package org.opengroup.osdu.aws.workflow.workflow;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opengroup.osdu.aws.workflow.util.HTTPClientAWS;
import org.opengroup.osdu.workflow.workflow.GetServiceInfoIntegrationTest;
public class TestGetServiceInfoIntegration extends GetServiceInfoIntegrationTest {
@BeforeEach
@Override
public void setup() throws Exception {
this.client = new HTTPClientAWS();
this.headers = client.getCommonHeader();
}
@AfterEach
@Override
public void tearDown() throws Exception {
this.client = null;
this.headers = null;
}
}
......@@ -116,7 +116,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.5</version>
<version>0.11.0-rc4</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
......
package org.opengroup.osdu.azure.workflow.workflow;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opengroup.osdu.azure.workflow.utils.HTTPClientAzure;
import org.opengroup.osdu.workflow.workflow.GetServiceInfoIntegrationTest;
public class TestGetServiceInfoIntegration extends GetServiceInfoIntegrationTest {
@BeforeEach
@Override
public void setup() throws Exception {
this.client = new HTTPClientAzure();
this.headers = client.getCommonHeader();
}
@AfterEach
@Override
public void tearDown() throws Exception {
this.client = null;
this.headers = null;
}
}
......@@ -36,7 +36,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
<jersey.version>1.19.4</jersey.version>
<os-core-common.version>0.3.6</os-core-common.version>
<os-core-common.version>0.11.0-rc4</os-core-common.version>
</properties>
<dependencyManagement>
......
......@@ -26,6 +26,7 @@ public class TestConstants {
public static final String CREATE_WORKFLOW_RUN_API_ENDPOINT = CREATE_WORKFLOW_API_ENDPOINT + "/%s/workflowRun";
public static final String GET_WORKFLOW_BY_ID_API_ENDPOINT = "v1/workflow/%s";
public static final String GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT = CREATE_WORKFLOW_API_ENDPOINT + "/%s/workflowRun/%s";
public static final String GET_SERVICE_INFO_API_ENDPOINT = "info";
public static final String GET_ALL_WORKFLOW_PREFIX = "?prefix=";
public static final String WORKFLOW_TYPE_INGEST = "ingest";
......@@ -56,6 +57,8 @@ public class TestConstants {
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT;
public static final String GET_DETAILS_WORKFLOW_RUN_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT;
public static final String GET_SERVICE_INFO_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_SERVICE_INFO_API_ENDPOINT;
public static final String NON_EXISTING_WORKFLOW_ID = "non-existing-workflow-id";
public static final String WORKFLOW_ID_NOT_BLANK_MESSAGE = "WorkflowID: must not be blank";
......
......@@ -73,7 +73,6 @@ public abstract class HTTPClient {
client.setConnectTimeout(10000);
WebResource webResource = client.resource(url);
log.info("URL = " + url );
log.info("Access token = " + token);
response = this.getClientResponse(httpMethod, payLoad, webResource, headers, token);
} catch (Exception e) {
e.printStackTrace();
......
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.
*/
package org.opengroup.osdu.workflow.util;
import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
import com.sun.jersey.api.client.ClientResponse;
public class VersionInfoUtils {
public VersionInfo getVersionInfoFromResponse(ClientResponse response) {
assertTrue(response.getType().toString().contains("application/json"));
String json = response.getEntity(String.class);
Gson gson = new Gson();
return gson.fromJson(json, VersionInfo.class);
}
public class VersionInfo {
public String groupId;
public String artifactId;
public String version;
public String buildTime;
public String branch;
public String commitId;
public String commitMessage;
}
}
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.
*/
package org.opengroup.osdu.workflow.workflow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.sun.jersey.api.client.ClientResponse;
import javax.ws.rs.HttpMethod;
import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;
import org.opengroup.osdu.workflow.consts.TestConstants;
import org.opengroup.osdu.workflow.util.TestBase;
import org.opengroup.osdu.workflow.util.VersionInfoUtils;
public abstract class GetServiceInfoIntegrationTest extends TestBase {
protected static final VersionInfoUtils VERSION_INFO_UTILS = new VersionInfoUtils();
@Test
public void should_returnInfo() throws Exception {
String url = TestConstants.GET_SERVICE_INFO_URL;
ClientResponse response = client.send(
HttpMethod.GET,
url,
null,
headers,
""
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
VersionInfoUtils.VersionInfo responseObject = VERSION_INFO_UTILS.getVersionInfoFromResponse(response);
assertNotNull(responseObject.groupId);
assertNotEquals("", responseObject.groupId);
assertNotNull(responseObject.artifactId);
assertNotEquals("", responseObject.artifactId);
assertNotNull(responseObject.version);
assertNotEquals("", responseObject.version);
assertNotNull(responseObject.buildTime);
assertNotEquals("", responseObject.buildTime);
assertNotNull(responseObject.branch);
assertNotEquals("", responseObject.branch);
assertNotNull(responseObject.commitId);
assertNotEquals("", responseObject.commitId);
assertNotNull(responseObject.commitMessage);
assertNotEquals("", responseObject.commitMessage);
}
}
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.
*/
package org.opengroup.osdu.gcp.workflow.workflow;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opengroup.osdu.gcp.workflow.util.HTTPClientGCP;
import org.opengroup.osdu.workflow.workflow.GetServiceInfoIntegrationTest;
public class TestGetServiceInfoIntegration extends GetServiceInfoIntegrationTest {
@BeforeEach
@Override
public void setup() throws Exception {
this.client = new HTTPClientGCP();
this.headers = this.client.getCommonHeader();
}
@AfterEach
@Override
public void tearDown() throws Exception {
this.client = null;
this.headers = null;
}
}
package org.opengroup.osdu.ibm.workflow.workflow.v3;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opengroup.osdu.ibm.workflow.util.HTTPClientIBM;
import org.opengroup.osdu.workflow.workflow.GetServiceInfoIntegrationTest;
public class TestGetServiceInfoIntegration extends GetServiceInfoIntegrationTest {
@BeforeEach
@Override
public void setup() throws Exception {
this.client = new HTTPClientIBM();
this.headers = client.getCommonHeader();
}
@AfterEach
@Override
public void tearDown() throws Exception {
this.client = null;
this.headers = null;
}
}
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* 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
*
* https://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.
*/
package org.opengroup.osdu.workflow.api;
import java.io.IOException;
import org.opengroup.osdu.core.common.info.VersionInfoBuilder;
import org.opengroup.osdu.core.common.model.info.VersionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class InfoApi {
@Autowired
private VersionInfoBuilder versionInfoBuilder;
@GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE)
public VersionInfo info() throws IOException {
return versionInfoBuilder.buildVersionInfo();
}
}
package org.opengroup.osdu.workflow.di;
import java.util.ArrayList;
import java.util.List;
import org.opengroup.osdu.core.common.info.ConnectedOuterServicesBuilder;
import org.opengroup.osdu.core.common.model.info.ConnectedOuterService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;
@Component
@ConditionalOnMissingBean(type = "ConnectedOuterServicesBuilder")
public class CloudConnectedOuterServicesBuilder implements ConnectedOuterServicesBuilder {
// TODO Need to implement this functionality after upgrading Airflow version,
// currently Airflow doesn't have public version info endpoint.
@Override
public List<ConnectedOuterService> buildConnectedOuterServices() {
return new ArrayList<>();
}
}
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