diff --git a/devops/gc/deploy/templates/deployment.yaml b/devops/gc/deploy/templates/deployment.yaml index bbbe24630d60710b4450a958655b2b16dc3135d0..8ebe82965043214dad1182637de62385ab7e6364 100644 --- a/devops/gc/deploy/templates/deployment.yaml +++ b/devops/gc/deploy/templates/deployment.yaml @@ -49,7 +49,7 @@ spec: livenessProbe: failureThreshold: 3 httpGet: - path: /api/search/v2/health/liveness_check + path: /api/search/v2/liveness_check port: 8080 initialDelaySeconds: 120 periodSeconds: 10 diff --git a/docs/api/search_openapi.yaml b/docs/api/search_openapi.yaml index 8287c0c94415669742607aee5a394cd219374b22..2357c7d1cecdfdcb4e5c8ddaff4ad5fab26c14f6 100644 --- a/docs/api/search_openapi.yaml +++ b/docs/api/search_openapi.yaml @@ -1,389 +1,507 @@ -swagger: "2.0" +openapi: 3.0.1 info: - description: "Search service" - version: "1.0.0" - title: "Search Service APIs" -host: "search-[OSDU].appspot.com" -x-google-allow: all -x-google-endpoints: -- name: "search-[OSDU].appspot.com" - allowCors: true -basePath: "/api/search/v2" -tags: -- name: search - description: Service endpoints to search data in datalake -- name: Search -- name: info - description: Version info endpoint -schemes: -- https -consumes: -- application/json -produces: -- application/json + title: Search Service + description: Search service that provides a set of APIs to search records against Elasticsearch + contact: + name: OSDU Data Platform Team + email: dps@OSDU.org + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + version: '2.0' +servers: + - url: /api/search/v2/ security: -- Bearer: [] -- google_id_token: [] + - Authorization: [] +tags: + - name: search-api + description: Service endpoints to search data in datalake + - name: health-check-api + description: Health Check API + - name: info + description: Version info endpoint paths: - "/query": + /query_with_cursor: post: tags: - - Search - summary: Queries the index for the specified kind using the input query string. - description: The API supports full text search on string fields, range queries on date, numeric or string fields, along with geo-spatial search. Required access levels to use this API are service.search.user, service.search.admin. In addition, users must be a member of data groups to access the data. - operationId: queryRecords - consumes: - - application/json - produces: - - application/json + - search-api + summary: Queries the index using cursor for the input request criteria. + description: |- + The API supports full text search on string fields, range queries on date, numeric or string fields, along with geo-spatial search. + Required roles: `users.datalake.viewers` or `users.datalake.editors` or `users.datalake.admins` or `users.datalake.ops`. In addition, users must be a member of data groups to access the data. + It can be used to retrieve large numbers of results (or even all results) from a single search request, in much the same way as you would use a cursor on a traditional database. + operationId: queryWithCursor parameters: - - name: OSDU-Account-Id - in: header - description: Account ID is the active OSDU account (OSDU account or customer's account) which the users choose to use with the Search API. - required: true - type: string - - name: OSDU-On-Behalf-Of - in: header - description: On behalf email or token is the token/email of the original user making the call. For now, only email is supported but eventually, primary usage will be token. - required: false - type: string - - in: body - name: body + - name: data-partition-id + in: header + description: Tenant Id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CursorQueryRequest' required: true - description: Specifies the API parameters. The only required parameter is the kind which needs to be formatted correctly. - schema: - "$ref": "#/definitions/QueryRequest" responses: '200': - description: Success. - schema: - "$ref": "#/definitions/QueryResponse" + description: Success + content: + '*/*': + schema: + $ref: '#/components/schemas/CursorQueryResponse' '400': - description: Invalid parameters were given on request / Unrecognized fields found on request/ Bad JSON format. - schema: - "$ref": "#/definitions/AppError" + description: Invalid parameters were given on request + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '401': + description: Unauthorized + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' '403': - description: User not authorized to perform the action. - schema: - "$ref": "#/definitions/AppError" + description: User not authorized to perform the action + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' '404': - description: Resource you are trying to find does not exists - schema: - "$ref": "#/definitions/AppError" + description: Not Found + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '500': + description: Internal Server Error + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '502': + description: Search service scale-up is taking longer than expected. Wait 10 seconds and retry. + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '503': + description: Service Unavailable + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' security: - - Bearer: [] - - google_id_token: [] - "/query_with_cursor": + - Authorization: [] + /query: post: tags: - - Search - summary: Query the index using cursor and optionally return only requested fields. - description: The API supports full text search on string fields, range queries on date, numeric or string fields, along with geo-spatial search. Required access levels to use this API are service.search.user, service.search.admin. In addition, users must be a member of data groups to access the data. It can be used to retrieve large numbers of results (or even all results) from a single search request, in much the same way as you would use a cursor on a traditional database. - operationId: queryWithCursor - consumes: - - application/json - produces: - - application/json + - search-api + summary: Queries the index for the input request criteria. + description: |- + The API supports full text search on string fields, range queries on date, numeric or string fields, along with geo-spatial search. + Required roles: `users.datalake.viewers` or `users.datalake.editors` or `users.datalake.admins` or `users.datalake.ops`. In addition, users must be a member of data groups to access the data. + operationId: queryRecords parameters: - - name: OSDU-Account-Id - in: header - description: Account ID is the active OSDU account (OSDU account or customer's account) which the users choose to use with the Search API. - required: true - type: string - - name: OSDU-On-Behalf-Of - in: header - description: On behalf email or token is the token/email of the original user making the call. For now, only email is supported but eventually, primary usage will be token. - required: false - type: string - - in: body - name: body + - name: data-partition-id + in: header + description: Tenant Id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/QueryRequest' required: true - description: Specifies the API parameters. The only required parameter is the kind which needs to be formatted correctly. - schema: - "$ref": "#/definitions/CursorQueryRequest" responses: '200': - description: Success. - schema: - "$ref": "#/definitions/CursorQueryResponse" + description: Success + content: + '*/*': + schema: + $ref: '#/components/schemas/QueryResponse' '400': - description: Invalid parameters were given on request / Unrecognized fields found on request/ Bad JSON format. - schema: - "$ref": "#/definitions/AppError" + description: Invalid parameters were given on request + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '401': + description: Unauthorized + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' '403': - description: User not authorized to perform the action. - schema: - "$ref": "#/definitions/AppError" + description: User not authorized to perform the action + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' '404': - description: Resource you are trying to find does not exists - schema: - "$ref": "#/definitions/AppError" + description: Not Found + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '500': + description: Internal Server Error + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '502': + description: Search service scale-up is taking longer than expected. Wait 10 seconds and retry. + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '503': + description: Service Unavailable + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' security: - - Bearer: [] - - google_id_token: [] + - Authorization: [] + /readiness_check: + get: + tags: + - health-check-api + summary: Readiness Check endpoint + description: For deployment available public `/readiness_check` endpoint. + operationId: readinessCheck + parameters: + - name: data-partition-id + in: header + description: Tenant Id + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + type: string + '502': + description: Bad Gateway + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '503': + description: Service Unavailable + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + /liveness_check: + get: + tags: + - health-check-api + summary: Liveness Check endpoint + description: ${healthCheckApi.livenessCheck.description} + operationId: livenessCheck + parameters: + - name: data-partition-id + in: header + description: Tenant Id + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + type: string + '502': + description: Bad Gateway + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' + '503': + description: Service Unavailable + content: + '*/*': + schema: + $ref: '#/components/schemas/AppError' /info: get: tags: - info - summary: "Version info" - description: "For deployment available public `/info` endpoint, \ - \ which provides build and git related information." - operationId: "Version info" - produces: - - "application/json" - responses: - 200: - description: "Version info." + summary: Version info + description: For deployment available public `/info` endpoint, which provides build and git related information. + operationId: info + parameters: + - name: data-partition-id + in: header + description: Tenant Id + required: true schema: - $ref: "#/definitions/VersionInfo" -definitions: - AppError: - type: object - properties: - code: - type: integer - format: int32 - reason: - type: string - message: - type: string - QueryResponse: - type: object - properties: - results: - type: array - items: + type: string + responses: + '200': + description: Version info. + content: + application/json: + schema: + $ref: '#/components/schemas/VersionInfo' +components: + schemas: + ByBoundingBox: + required: + - bottomRight + - topLeft + type: object + properties: + topLeft: + $ref: '#/components/schemas/Point' + bottomRight: + $ref: '#/components/schemas/Point' + ByDistance: + required: + - point + type: object + properties: + distance: + maximum: 9223372036854776000 + type: number + format: double + point: + $ref: '#/components/schemas/Point' + ByGeoPolygon: + required: + - points + type: object + properties: + points: + type: array + items: + $ref: '#/components/schemas/Point' + ByIntersection: + required: + - polygons + type: object + properties: + polygons: + type: array + items: + $ref: '#/components/schemas/Polygon' + ByWithinPolygon: + required: + - points + type: object + properties: + points: + type: array + items: + $ref: '#/components/schemas/Point' + CursorQueryRequest: + required: + - kind + type: object + properties: + kind: type: object - additionalProperties: - type: object - totalCount: - type: integer - format: int64 - ByBoundingBox: - title: Query by bounding box - description : A spatial filter criteria to allow to filter documents based on a point location within a bounding box. - type: object - required: - - topLeft - - bottomRight - properties: - topLeft: - "$ref": "#/definitions/Point" - bottomRight: - "$ref": "#/definitions/Point" - ByDistance: - title: Query by distance - description: A spatial filter criteria to filter documents that exist within a specific distance from a geo point. - type: object - required: - - point - properties: - distance: - type: number - format: double - minimum: 0 - point: - "$ref": "#/definitions/Point" - ByGeoPolygon: - title: Query by polygon - description: A spatial filter criteria to filter documents which falls within a polygon of points. - type: array - items: - "$ref": "#/definitions/Point" - required: - - points - properties: - points: - type: array - items: - "$ref": "#/definitions/Point" - Point: - title: Point - description: Geo-point with latitude and longitude - type: object - properties: - latitude: - type: number - format: double - minimum: -90 - maximum: 90 - longitude: - type: number - format: double - minimum: -180 - maximum: 180 - QueryRequest: - description: Json object to query the Search API - type: object - required: - - kind - properties: - offset: - type: integer - format: int32 - minimum: 0 - description: The starting offset from which to return results - kind: - type: object - description: The kind of the record to query e.g. "tenant1:test:well:1.0.0" or "tenant1:test:well:1.0.0,tenant1:test:well:2.0.0" or ["tenant1:test:well:1.0.0", "tenant1:test:well:2.0.0"]. - limit: - type: integer - format: int32 - minimum: 0 - description: The maximum number of results to return from the given offset. If no limit is provided, then it will return 10 items. Max number of items which can be fetched by the query is 1000. - query: - type: string - description: The query string in Lucene query string syntax. - spatialFilter: - "$ref": "#/definitions/SpatialFilter" - returnedFields: - type: array - items: + limit: + minimum: 0 + type: integer + format: int32 + query: + type: string + highlightedFields: + type: array + items: + type: string + returnedFields: + type: array + items: + type: string + sort: + $ref: '#/components/schemas/SortQuery' + queryAsOwner: + type: boolean + trackTotalCount: + type: boolean + spatialFilter: + $ref: '#/components/schemas/SpatialFilter' + cursor: + type: string + Point: + type: object + properties: + latitude: + maximum: 90 + minimum: -90 + type: number + format: double + longitude: + type: number + format: double + Polygon: + type: object + properties: + points: + type: array + items: + $ref: '#/components/schemas/Point' + SortQuery: + type: object + properties: + field: + type: array + items: + type: string + order: + type: array + items: + type: string + enum: + - ASC + - DESC + filter: + type: array + items: + type: string + SpatialFilter: + required: + - field + type: object + properties: + field: type: string - description: The fields on which to project the results. - example: - offset: 10 - kind: tenant1:test:well:1.0.0 - limit: 30 - query: Status:Active - spatialFilter: - field: Location byBoundingBox: - topLeft: - latitude: 37.450727 - longitude: -122.174762 - bottomRight: - latitude: 36.450727 - longitude: 122.174762 - returnedFields: [Location] - SpatialFilter: - title: Spatial Filter - description: This filter is used to filter geo-point geo data which supports lat/lon pairs. The queries in this group are Geo Distance, Geo Polygon and Bounding Box. Only one spatial criteria can be used while defining filter. - type: object - required: - - field - properties: - field: - type: string - description: geo-point field in the index on which filtering will be performed. - byBoundingBox: - "$ref": "#/definitions/ByBoundingBox" - byDistance: - "$ref": "#/definitions/ByDistance" - byGeoPolygon: - "$ref": "#/definitions/ByGeoPolygon" - CursorQueryResponse: - type: object - properties: - cursor: - type: string - results: - type: array - items: + $ref: '#/components/schemas/ByBoundingBox' + byDistance: + $ref: '#/components/schemas/ByDistance' + byGeoPolygon: + $ref: '#/components/schemas/ByGeoPolygon' + byIntersection: + $ref: '#/components/schemas/ByIntersection' + byWithinPolygon: + $ref: '#/components/schemas/ByWithinPolygon' + CursorQueryResponse: + type: object + properties: + cursor: + type: string + results: + type: array + items: + type: object + additionalProperties: + type: object + totalCount: + type: integer + format: int64 + AppError: + type: object + properties: + code: + type: integer + format: int32 + reason: + type: string + message: + type: string + QueryRequest: + required: + - kind + type: object + properties: + kind: type: object - additionalProperties: + limit: + minimum: 0 + type: integer + format: int32 + query: + type: string + highlightedFields: + type: array + items: + type: string + returnedFields: + type: array + items: + type: string + sort: + $ref: '#/components/schemas/SortQuery' + queryAsOwner: + type: boolean + trackTotalCount: + type: boolean + spatialFilter: + $ref: '#/components/schemas/SpatialFilter' + aggregateBy: + type: string + offset: + minimum: 0 + type: integer + format: int32 + AggregationResponse: + type: object + properties: + key: + type: string + count: + type: integer + format: int64 + QueryResponse: + type: object + properties: + results: + type: array + items: type: object - totalCount: - type: integer - format: int64 - CursorQueryRequest: - description: Json object to query the Search API - type: object - required: - - kind - properties: - cursor: - type: string - description: The cursor value returned from a previous query. - kind: - type: object - description: The kind of the record to query e.g. "tenant1:test:well:1.0.0" or "tenant1:test:well:1.0.0,tenant1:test:well:2.0.0" or ["tenant1:test:well:1.0.0", "tenant1:test:well:2.0.0"]. - limit: - type: integer - format: int32 - minimum: 0 - description: The maximum number of results to return from the given offset. If no limit is provided, then it will return 10 items. Max number of items which can be fetched by the query is 1000. - query: - type: string - description: The query string in Lucene query string syntax. - spatialFilter: - "$ref": "#/definitions/SpatialFilter" - returnedFields: - type: array - items: + additionalProperties: + type: object + aggregations: + type: array + items: + $ref: '#/components/schemas/AggregationResponse' + totalCount: + type: integer + format: int64 + ConnectedOuterService: + type: object + properties: + name: type: string - description: The fields on which to project the results. - example: - cursor: yyyyyyy - kind: tenant1:test:well:1.0.0 - limit: 30 - query: Status:Active - spatialFilter: - field: Location - byBoundingBox: - topLeft: - latitude: 37.450727 - longitude: -122.174762 - bottomRight: - latitude: 36.450727 - longitude: 122.174762 - returnedFields: [Location] - 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: "#/definitions/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." - # This section is the general responses shared by all apis - GeneralResponse: - properties: - 502: - description: Too many requests are received in short period of time. Please retry later. -# This section requires all requests to any path to require an API key. -securityDefinitions: - google_id_token: - authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth" - flow: "implicit" - type: "oauth2" - x-google-issuer: "https://accounts.google.com" - x-google-jwks_uri: "https://www.googleapis.com/oauth2/v3/certs" - scopes: {} - #Security configuration or the portal - Bearer: - type: apiKey - name: Authorization - in: header + version: + type: string + VersionInfo: + type: object + properties: + groupId: + type: string + artifactId: + type: string + version: + type: string + buildTime: + type: string + branch: + type: string + commitId: + type: string + commitMessage: + type: string + connectedOuterServices: + type: array + items: + $ref: '#/components/schemas/ConnectedOuterService' + securitySchemes: + Authorization: + type: http + scheme: bearer + bearerFormat: Authorization \ No newline at end of file diff --git a/provider/search-gc/docs/baremetal/README.md b/provider/search-gc/docs/baremetal/README.md index 7e0e9152c51c92c164a988a1f34a40566ac17d4e..81d150b2b113c96d58caeec943e64391a69e5c09 100644 --- a/provider/search-gc/docs/baremetal/README.md +++ b/provider/search-gc/docs/baremetal/README.md @@ -37,23 +37,23 @@ Must have: Defined in default application property file but possible to override: -| name | value | description | sensitive? | source | -|------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------|------------|------------------------------------------------------------| -| `LOG_PREFIX` | `service` | Logging prefix | no | - | -| `SERVER_SERVLET_CONTEXPATH` | `/api/search/v2/` | Servlet context path | no | - | -| `AUTHORIZE_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment | -| `REDIS_SEARCH_HOST` | ex `records-changed` | Redis host for search | no | | -| `REDIS_SEARCH_PORT` | ex `6379` | Redis port for search | no | | -| `REDIS_SEARCH_PASSWORD` | ex `127.0.0.1` | Redis search host password | yes | | -| `REDIS_SEARCH_WITH_SSL` | ex `true` or `false` | Redis search host ssl config | no | | -| `REDIS_SEARCH_EXPIRATION` | ex `30` | Redis search cache expiration in seconds | no | | +| name | value | description | sensitive? | source | +|------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------|------------|--------------------------------------------------------------| +| `LOG_PREFIX` | `service` | Logging prefix | no | - | +| `SERVER_SERVLET_CONTEXPATH` | `/api/search/v2/` | Servlet context path | no | - | +| `AUTHORIZE_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment | +| `REDIS_SEARCH_HOST` | ex `records-changed` | Redis host for search | no | | +| `REDIS_SEARCH_PORT` | ex `6379` | Redis port for search | no | | +| `REDIS_SEARCH_PASSWORD` | ex `127.0.0.1` | Redis search host password | yes | | +| `REDIS_SEARCH_WITH_SSL` | ex `true` or `false` | Redis search host ssl config | no | | +| `REDIS_SEARCH_EXPIRATION` | ex `30` | Redis search cache expiration in seconds | no | | | `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | <https://console.cloud.google.com/iam-admin/serviceaccounts> | -| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | -| `PARTITION_API` | ex `http://localhost:8080/api/partition/v1` | Partition service endpoint | no | output of infrastructure deployment | -| `POLICY_API` | ex `http://localhost:8080/api/policy/v1/` | Policy service endpoint | no | output of infrastructure deployment | -| `POLICY_ID` | ex `search` | policyId from ex `http://localhost:8080/api/policy/v1/policies`. Look at `POLICY_API` | no | - | -| `SERVICE_POLICY_ENABLED` | ex `false` | Enable or Disable an integration with Policy Service | no | output of infrastructure deployment | -| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | +| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | +| `PARTITION_API` | ex `http://localhost:8080/api/partition/v1` | Partition service endpoint | no | output of infrastructure deployment | +| `POLICY_API` | ex `http://localhost:8080/api/policy/v1/` | Policy service endpoint | no | output of infrastructure deployment | +| `POLICY_ID` | ex `search` | policyId from ex `http://localhost:8080/api/policy/v1/policies`. Look at `POLICY_API` | no | - | +| `SERVICE_POLICY_ENABLED` | ex `false` | Enable or Disable an integration with Policy Service | no | output of infrastructure deployment | +| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | These variables define service behavior, and are used to switch between `Reference` or `Google Cloud` environments, their overriding and usage in mixed mode was not tested. Usage of spring profiles is preferred. @@ -92,12 +92,12 @@ It can be overridden by: **Propertyset:** -| Property | Description | -| --- | --- | -| elasticsearch.host | server URL | -| elasticsearch.port | server port | -| elasticsearch.user | username | -| elasticsearch.password | password | +| Property | Description | +|------------------------|-------------| +| elasticsearch.host | server URL | +| elasticsearch.port | server port | +| elasticsearch.user | username | +| elasticsearch.password | password | <details><summary>Example of a definition for a single tenant</summary></details> @@ -147,28 +147,28 @@ Give `client-id` and `client-secret` to services, which should be authorized wit You will need to have the following environment variables defined. -| name | value | description | sensitive? | source | -| --- | --- | --- | --- | --- | -| `ELASTIC_PASSWORD` | `********` | Password for Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_USER_NAME` | `********` | User name for Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_HOST` | ex `elastic.domain.com` | Host Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_PORT` | ex `9243` | Port Elasticsearch | yes | output of infrastructure deployment | -| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | -| `DATA_GROUP` | `opendes` | The service account to this group and substitute | no | - | -| `GROUP_ID` | ex `opendes-gc.projects.com` | OSDU R2 to run tests under | no | - | -| `DEFAULT_DATA_PARTITION_ID_TENANT1` | ex `opendes` | HTTP Header 'Data-Partition-ID' | no | - | -| `DEFAULT_DATA_PARTITION_ID_TENANT2` | ex `not-exist` | HTTP Header 'Data-Partition-ID' with not existing tenant | no | - | -| `SEARCH_HOST` | ex `http://localhost:8080/api/search/v2/` | Endpoint of search service | no | - | -| `LEGAL_TAG` | ex `my-legal-tag` | a valid legal tag | no | - | -| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | -| `TEST_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `$INTEGRATION_TESTER` | yes | -- | -| `TEST_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `$INTEGRATION_TESTER` | -- | -| `TEST_OPENID_PROVIDER_URL` | `https://keycloak.com/auth/realms/osdu` | OpenID provider url | yes | -- | +| name | value | description | sensitive? | source | +|--------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------|-----------------------------------------|-------------------------------------| +| `ELASTIC_PASSWORD` | `********` | Password for Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_USER_NAME` | `********` | User name for Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_HOST` | ex `elastic.domain.com` | Host Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_PORT` | ex `9243` | Port Elasticsearch | yes | output of infrastructure deployment | +| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | +| `DATA_GROUP` | `opendes` | The service account to this group and substitute | no | - | +| `GROUP_ID` | ex `opendes-gc.projects.com` | OSDU R2 to run tests under | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT1` | ex `opendes` | HTTP Header 'Data-Partition-ID' | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT2` | ex `not-exist` | HTTP Header 'Data-Partition-ID' with not existing tenant | no | - | +| `SEARCH_HOST` | ex `http://localhost:8080/api/search/v2/` | Endpoint of search service | no | - | +| `LEGAL_TAG` | ex `my-legal-tag` | a valid legal tag | no | - | +| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | +| `TEST_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `$INTEGRATION_TESTER` | yes | -- | +| `TEST_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `$INTEGRATION_TESTER` | -- | +| `TEST_OPENID_PROVIDER_URL` | `https://keycloak.com/auth/realms/osdu` | OpenID provider url | yes | -- | **Entitlements configuration for integration accounts** | INTEGRATION_TESTER | NO_DATA_ACCESS_TESTER | -|----------------------------------------------------------------------------------------------------------------------------------------| --- | +|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------| | users<br/>service.entitlements.user<br/>service.search.user<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{groupId}.com | Execute following command to build code and run all the integration tests: diff --git a/provider/search-gc/docs/gc/README.md b/provider/search-gc/docs/gc/README.md index ad8a08b6ce469c9ef712091c68b2427e312d94ec..4dc7f64c72bd135a84fe556f07efce5e115c42da 100644 --- a/provider/search-gc/docs/gc/README.md +++ b/provider/search-gc/docs/gc/README.md @@ -37,22 +37,22 @@ Must have: Defined in default application property file but possible to override: -| name | value | description | sensitive? | source | -|------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------|------------|------------------------------------------------------------| -| `LOG_PREFIX` | `service` | Logging prefix | no | - | -| `SERVER_SERVLET_CONTEXPATH` | `/api/search/v2/` | Servlet context path | no | - | -| `AUTHORIZE_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment || `REDIS_SEARCH_HOST` | ex `records-changed` | Redis host for search | no | | -| `REDIS_SEARCH_PORT` | ex `6379` | Redis port for search | no | | -| `REDIS_SEARCH_PASSWORD` | ex `*****` | Redis search host password | yes | | -| `REDIS_SEARCH_WITH_SSL` | ex `true` or `false` | Redis search host ssl config | no | | -| `REDIS_SEARCH_EXPIRATION` | ex `30` | Redis search cache expiration in seconds | no | | +| name | value | description | sensitive? | source | +|------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------|------------|--------------------------------------------------------------| +| `LOG_PREFIX` | `service` | Logging prefix | no | - | +| `SERVER_SERVLET_CONTEXPATH` | `/api/search/v2/` | Servlet context path | no | - | +| `AUTHORIZE_API` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment || `REDIS_SEARCH_HOST` | ex `records-changed` | Redis host for search | no | | +| `REDIS_SEARCH_PORT` | ex `6379` | Redis port for search | no | | +| `REDIS_SEARCH_PASSWORD` | ex `*****` | Redis search host password | yes | | +| `REDIS_SEARCH_WITH_SSL` | ex `true` or `false` | Redis search host ssl config | no | | +| `REDIS_SEARCH_EXPIRATION` | ex `30` | Redis search cache expiration in seconds | no | | | `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | <https://console.cloud.google.com/iam-admin/serviceaccounts> | -| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | -| `PARTITION_API` | ex `http://localhost:8080/api/partition/v1` | Partition service endpoint | no | output of infrastructure deployment | -| `POLICY_API` | ex `http://localhost:8080/api/policy/v1/` | Policy service endpoint | no | output of infrastructure deployment | -| `POLICY_ID` | ex `search` | policyId from ex `http://localhost:8080/api/policy/v1/policies`. Look at `POLICY_API` | no | - | -| `SERVICE_POLICY_ENABLED` | ex `false` | Enable or Disable an integration with Policy Service | no | output of infrastructure deployment | -| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | +| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | +| `PARTITION_API` | ex `http://localhost:8080/api/partition/v1` | Partition service endpoint | no | output of infrastructure deployment | +| `POLICY_API` | ex `http://localhost:8080/api/policy/v1/` | Policy service endpoint | no | output of infrastructure deployment | +| `POLICY_ID` | ex `search` | policyId from ex `http://localhost:8080/api/policy/v1/policies`. Look at `POLICY_API` | no | - | +| `SERVICE_POLICY_ENABLED` | ex `false` | Enable or Disable an integration with Policy Service | no | output of infrastructure deployment | +| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | These variables define service behavior, and are used to switch between `Reference` or `Google Cloud` environments, their overriding and usage in mixed mode was not tested. Usage of spring profiles is preferred. @@ -91,12 +91,12 @@ It can be overridden by: **Propertyset:** -| Property | Description | -| --- | --- | -| elasticsearch.host | server URL | -| elasticsearch.port | server port | -| elasticsearch.user | username | -| elasticsearch.password | password | +| Property | Description | +|------------------------|-------------| +| elasticsearch.host | server URL | +| elasticsearch.port | server port | +| elasticsearch.user | username | +| elasticsearch.password | password | <details><summary>Example of a definition for a single tenant</summary></details> @@ -130,35 +130,35 @@ curl -L -X PATCH 'http://partition.com/api/partition/v1/partitions/opendes' -H ' TBD | Required roles | -| --- | -| - | +|----------------| +| - | ### Running E2E Tests You will need to have the following environment variables defined. -| name | value | description | sensitive? | source | -| --- | --- | --- | --- | --- | -| `ENTITLEMENTS_HOST` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment | -| `ELASTIC_PASSWORD` | `********` | Password for Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_USER_NAME` | `********` | User name for Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_HOST` | ex `elastic.domain.com` | Host Elasticsearch | yes | output of infrastructure deployment | -| `ELASTIC_PORT` | ex `9243` | Port Elasticsearch | yes | output of infrastructure deployment | -| `GCLOUD_PROJECT` | ex `opendes` | Google Cloud Project Id| no | output of infrastructure deployment | -| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | -| `DATA_GROUP` | `opendes` | The service account to this group and substitute | no | - | -| `GROUP_ID` | ex `opendes-gcp.projects.com` | OSDU R2 to run tests under | no | - | -| `DEFAULT_DATA_PARTITION_ID_TENANT1` | ex `opendes` | HTTP Header 'Data-Partition-ID' | no | - | -| `DEFAULT_DATA_PARTITION_ID_TENANT2` | ex `not-exist` | HTTP Header 'Data-Partition-ID' with not existing tenant | no | - | -| `SEARCH_INTEGRATION_TESTER` | `********` | Service account for API calls. Note: this user must have entitlements configured already | yes | <https://console.cloud.google.com/iam-admin/serviceaccounts> | -| `SEARCH_HOST` | ex `http://localhost:8080/api/search/v2/` | Endpoint of search service | no | - | -| `LEGAL_TAG` | ex `my-legal-tag` | a valid legal tag | no | - | -| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | +| name | value | description | sensitive? | source | +|-------------------------------------|-----------------------------------------------------------------|------------------------------------------------------------------------------------------|------------|--------------------------------------------------------------| +| `ENTITLEMENTS_HOST` | ex `https://entitlements.com/entitlements/v1` | Entitlements API endpoint | no | output of infrastructure deployment | +| `ELASTIC_PASSWORD` | `********` | Password for Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_USER_NAME` | `********` | User name for Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_HOST` | ex `elastic.domain.com` | Host Elasticsearch | yes | output of infrastructure deployment | +| `ELASTIC_PORT` | ex `9243` | Port Elasticsearch | yes | output of infrastructure deployment | +| `GCLOUD_PROJECT` | ex `opendes` | Google Cloud Project Id | no | output of infrastructure deployment | +| `INDEXER_HOST` | ex `https://os-indexer-dot-opendes.appspot.com/api/indexer/v2/` | Indexer API endpoint | no | output of infrastructure deployment | +| `DATA_GROUP` | `opendes` | The service account to this group and substitute | no | - | +| `GROUP_ID` | ex `opendes-gcp.projects.com` | OSDU R2 to run tests under | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT1` | ex `opendes` | HTTP Header 'Data-Partition-ID' | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT2` | ex `not-exist` | HTTP Header 'Data-Partition-ID' with not existing tenant | no | - | +| `SEARCH_INTEGRATION_TESTER` | `********` | Service account for API calls. Note: this user must have entitlements configured already | yes | <https://console.cloud.google.com/iam-admin/serviceaccounts> | +| `SEARCH_HOST` | ex `http://localhost:8080/api/search/v2/` | Endpoint of search service | no | - | +| `LEGAL_TAG` | ex `my-legal-tag` | a valid legal tag | no | - | +| `SECURITY_HTTPS_CERTIFICATE_TRUST` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment | **Entitlements configuration for integration accounts** | INTEGRATION_TESTER | NO_DATA_ACCESS_TESTER | -|----------------------------------------------------------------------------------------------------------------------------------------| --- | +|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------| | users<br/>service.entitlements.user<br/>service.search.user<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{groupId}.com | Execute following command to build code and run all the integration tests: diff --git a/search-core/src/main/java/org/opengroup/osdu/search/api/HealthCheckApi.java b/search-core/src/main/java/org/opengroup/osdu/search/api/HealthCheckApi.java index 831c19df1be13bb283ae99c429efa2f55adaa2d9..51eb86782da0f8642e8b676ec85026add8493b7a 100644 --- a/search-core/src/main/java/org/opengroup/osdu/search/api/HealthCheckApi.java +++ b/search-core/src/main/java/org/opengroup/osdu/search/api/HealthCheckApi.java @@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import org.opengroup.osdu.core.common.model.http.AppError; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -15,29 +16,57 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.security.PermitAll; @RestController -@RequestMapping("/health") +@RequestMapping("/") @Tag(name = "health-check-api", description = "Health Check API") public class HealthCheckApi { - @Operation(summary = "${healthChecksApi.livenessCheck.summary}", - description = "${healthChecksApi.livenessCheck.description}", tags = { "health-check-api" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK", content = { @Content(schema = @Schema(implementation = String.class)) }) - }) - @PermitAll - @GetMapping("/liveness_check") - public ResponseEntity<String> livenessCheck() { - return new ResponseEntity<String>("Search Service is alive", HttpStatus.OK); - } + @Operation( + summary = "${healthChecksApi.livenessCheck.summary}", + description = "${healthCheckApi.livenessCheck.description}", + tags = {"health-check-api"}) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK", + content = {@Content(schema = @Schema(implementation = String.class))}), + @ApiResponse( + responseCode = "502", + description = "Bad Gateway", + content = {@Content(schema = @Schema(implementation = AppError.class))}), + @ApiResponse( + responseCode = "503", + description = "Service Unavailable", + content = {@Content(schema = @Schema(implementation = AppError.class))}) + }) + @PermitAll + @GetMapping("/liveness_check") + public ResponseEntity<String> livenessCheck() { + return new ResponseEntity<>("Search Service is alive", HttpStatus.OK); + } - @Operation(summary = "${healthChecksApi.readinessCheck.summary}", - description = "${healthChecksApi.readinessCheck.description}", tags = { "health-check-api" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK", content = { @Content(schema = @Schema(implementation = String.class)) }) - }) - @PermitAll - @GetMapping("/readiness_check") - public ResponseEntity<String> readinessCheck() { - return new ResponseEntity<String>("Search Service is ready", HttpStatus.OK); - } + @Operation( + summary = "${healthChecksApi.readinessCheck.summary}", + description = "${healthChecksApi.readinessCheck.description}", + tags = {"health-check-api"}) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK", + content = {@Content(schema = @Schema(implementation = String.class))}), + @ApiResponse( + responseCode = "502", + description = "Bad Gateway", + content = {@Content(schema = @Schema(implementation = AppError.class))}), + @ApiResponse( + responseCode = "503", + description = "Service Unavailable", + content = {@Content(schema = @Schema(implementation = AppError.class))}) + }) + @PermitAll + @GetMapping("/readiness_check") + public ResponseEntity<String> readinessCheck() { + return new ResponseEntity<>("Search Service is ready", HttpStatus.OK); + } } diff --git a/search-core/src/main/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilter.java b/search-core/src/main/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilter.java index c7d4f9202a9669ad21c5411013dfa1ecc0fba2fb..1e90bc6aeee82842a8068e42c2cf2d240c9c8dbe 100644 --- a/search-core/src/main/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilter.java +++ b/search-core/src/main/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilter.java @@ -14,29 +14,23 @@ package org.opengroup.osdu.search.middleware; -import java.io.IOException; -import java.time.Duration; -import java.util.Map; - -import javax.inject.Inject; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import com.google.common.base.Strings; import org.apache.http.HttpStatus; import org.opengroup.osdu.core.common.http.ResponseHeadersFactory; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.Request; -import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.time.Duration; +import java.util.Map; + @Component public class CorrelationIDRequestFilter implements Filter { @Inject @@ -82,10 +76,6 @@ public class CorrelationIDRequestFilter implements Filter { startTime = (long)property; } - String path = httpRequest.getServletPath(); - if (path.endsWith("/liveness_check") || path.endsWith("/readiness_check")) - return; - String fetchConversionHeader = ((HttpServletRequest) request).getHeader(FOR_HEADER_NAME); if (!Strings.isNullOrEmpty(fetchConversionHeader)) { this.requestHeaders.put(FOR_HEADER_NAME, fetchConversionHeader); diff --git a/search-core/src/test/java/org/opengroup/osdu/search/middleware/AuthorizationRequestFilterTest.java b/search-core/src/test/java/org/opengroup/osdu/search/middleware/AuthorizationRequestFilterTest.java index d31644ed5192acf0a88652dadf1185ce99e84179..6663c96f280715264ef6ed30161be6929ce31c51 100644 --- a/search-core/src/test/java/org/opengroup/osdu/search/middleware/AuthorizationRequestFilterTest.java +++ b/search-core/src/test/java/org/opengroup/osdu/search/middleware/AuthorizationRequestFilterTest.java @@ -106,8 +106,7 @@ public class AuthorizationRequestFilterTest { @Test public void should_skipFilter_when_requestingSwaggerEndpoint() throws Exception { when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/swagger.js"); - when(httpRequest.getRequestURI()).thenReturn("http://foobar/"); + when(httpRequest.getRequestURI()).thenReturn("http://foobar/swagger"); org.springframework.test.util.ReflectionTestUtils.setField(sut, "ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS", "custom-domain"); sut.doFilter(httpRequest, httpResponse, filterChain); @@ -124,7 +123,6 @@ public class AuthorizationRequestFilterTest { AuthorizationResponse authorizationResponse = AuthorizationResponse.builder().groups(groups).user("user.1").build(); when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/query"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/query"); HashMap<String,String> headers =new HashMap<String, String>(); @@ -148,7 +146,6 @@ public class AuthorizationRequestFilterTest { AuthorizationResponse authorizationResponse = AuthorizationResponse.builder().groups(groups).user("user.1").build(); when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/query"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/query"); HashMap<String,String> headers =new HashMap<String, String>(); @@ -173,7 +170,6 @@ public class AuthorizationRequestFilterTest { AuthorizationResponse authorizationResponse = AuthorizationResponse.builder().groups(groups).user("user.1").build(); when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/query"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/query"); HashMap<String,String> headers =new HashMap<String, String>(); @@ -191,7 +187,6 @@ public class AuthorizationRequestFilterTest { public void should_throwException_given_multipleAccountId_forNonQueryApi() throws Exception { when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/index/schema"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/index/schema"); HashMap<String,String> headers =new HashMap<String, String>(); @@ -213,7 +208,6 @@ public class AuthorizationRequestFilterTest { public void should_throwException_given_emptyAccountId() throws Exception { when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/query"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/query"); HashMap<String,String> headers = new HashMap<String, String>(); diff --git a/search-core/src/test/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilterTest.java b/search-core/src/test/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilterTest.java index cd16292cf13b0923849e3ae37b1f8b2da6874a10..a40c9a92a27b0ecb752a0f1634e3b90cb89e1a41 100644 --- a/search-core/src/test/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilterTest.java +++ b/search-core/src/test/java/org/opengroup/osdu/search/middleware/CorrelationIDRequestFilterTest.java @@ -87,7 +87,6 @@ public class CorrelationIDRequestFilterTest { final String CORRELATION_ID = "any previous correlation id"; when(httpRequest.getMethod()).thenReturn("GET"); - when(httpRequest.getServletPath()).thenReturn("/query"); when(httpRequest.getRequestURI()).thenReturn("http://foobar/query"); HashMap<String,String> headers =new HashMap<String, String>(); diff --git a/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..42511e5132258ac494945c1c9e0d0cd0ae8c1a6a --- /dev/null +++ b/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..b10b4cb0189eab847c33982877edb0fb4af566b3 --- /dev/null +++ b/testing/integration-tests/search-test-aws/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,41 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.AWSHTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new AWSHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new AWSHTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +} diff --git a/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..42511e5132258ac494945c1c9e0d0cd0ae8c1a6a --- /dev/null +++ b/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..9fbda85b1f5fba8d7b92c5aa32a004a0354ee4a7 --- /dev/null +++ b/testing/integration-tests/search-test-azure/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,41 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.AzureHTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new AzureHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new AzureHTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +} diff --git a/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..21247db1935c4d2c4e311b442c14a9a4ed5e539b --- /dev/null +++ b/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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 + * + * 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. + */ + +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..5053b347b0cd6e4dfb990bd682dcf9f153f3bb1a --- /dev/null +++ b/testing/integration-tests/search-test-baremetal/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,58 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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 + * + * 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. + */ + +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.AnthosHTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new AnthosHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new AnthosHTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +} diff --git a/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/common/health/HealthSteps.java b/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/common/health/HealthSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..ecb35ad4ae2ced1190f16c63ff0947397945e0e9 --- /dev/null +++ b/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/common/health/HealthSteps.java @@ -0,0 +1,60 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2021-2023 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.common.health; + +import com.sun.jersey.api.client.ClientResponse; +import org.opengroup.osdu.common.TestsBase; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +import static org.junit.Assert.assertEquals; + +public class HealthSteps extends TestsBase { + protected String api; + + public HealthSteps(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return api; + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + private ClientResponse response; + + public void i_send_get_request_to_liveness_endpoint() { + api = Config.getSearchBaseURL() + "liveness_check"; + + response = executeGetRequest(api, headers, null); + } + + public void i_send_get_request_to_readiness_endpoint() { + api = Config.getSearchBaseURL() + "readiness_check"; + response = executeGetRequest(api, headers, null); + } + + public void i_should_get_OK_in_response() { + assertEquals(200, response.getStatus()); + } +} diff --git a/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/response/HealthResponseMock.java b/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/response/HealthResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..d86784d6335d259b875ea6310b5cc477f568f045 --- /dev/null +++ b/testing/integration-tests/search-test-core/src/main/java/org/opengroup/osdu/response/HealthResponseMock.java @@ -0,0 +1,25 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2021-2023 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.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class HealthResponseMock extends ResponseBase {} diff --git a/testing/integration-tests/search-test-core/src/main/resources/features/health/Health.feature b/testing/integration-tests/search-test-core/src/main/resources/features/health/Health.feature new file mode 100644 index 0000000000000000000000000000000000000000..18c26100a1e1c16d8d4a77db3279a7b698d5a7a1 --- /dev/null +++ b/testing/integration-tests/search-test-core/src/main/resources/features/health/Health.feature @@ -0,0 +1,10 @@ +Feature: To verify health api endpoints content + + Scenario: Verify liveness check endpoint content + Given I send get request to liveness check endpoint + Then service should respond back with 200 in response + + + Scenario: Verify readiness check endpoint content + Given I send get request to readiness check endpoint + Then service should respond back with 200 in response \ No newline at end of file diff --git a/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..21247db1935c4d2c4e311b442c14a9a4ed5e539b --- /dev/null +++ b/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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 + * + * 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. + */ + +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..6e6bd1fb49067eea04e874496c8965890229fbd8 --- /dev/null +++ b/testing/integration-tests/search-test-gc/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,58 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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 + * + * 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. + */ + +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.GCPHTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new GCPHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new GCPHTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +} diff --git a/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..42511e5132258ac494945c1c9e0d0cd0ae8c1a6a --- /dev/null +++ b/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..dedda6d34ff10c8da9ceea94e543177c4b94683b --- /dev/null +++ b/testing/integration-tests/search-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,41 @@ +package org.opengroup.osdu.step_definitions.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.IBMHTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new IBMHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new IBMHTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +}