Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Notification
Commits
46c8b516
Commit
46c8b516
authored
Oct 21, 2021
by
Rucha Deshpande
Browse files
Merge branch 'dev' into deshruch
parents
0bfab1d9
3930fafc
Pipeline
#74115
failed with stages
in 19 minutes and 13 seconds
Changes
7
Pipelines
3
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
46c8b516
variables
:
OSDU_GCP_APPLICATION_NAME
:
os-notification
OSDU_GCP_CLOUD_RUN_PARAMETERS
:
"
--min-instances=1"
OSDU_GCP_VENDOR
:
gcp
OSDU_GCP_SERVICE
:
notification
OSDU_GCP_REGISTER_BASE_URL
:
https://os-register-attcrcktoa-uc.a.run.app/api/register/v1
OSDU_GCP_ENV_VARS
:
APP_PROJECT=$OSDU_GCP_PROJECT,APP_ENTITLEMENTS=$OSDU_GCP_ENTITLEMENTS_V2_URL,APP_REGISTER=$OSDU_GCP_REGISTER_BASE_URL,APP_GOOGLEAUDIENCE=$GOOGLE_AUDIENCE,PARTITION_API=$OSDU_GCP_PARTITION_API,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE
OSDU_GCP_ENVIRONMENT
:
dev_gke
OSDU_GCP_LOG_LEVEL
:
INFO
OSDU_GCP_VENDOR
:
gcp
OSDU_GCP_HELM_DEPLOYMENT_DIR
:
"
devops/gcp/deploy"
OSDU_GCP_HELM_CONFIG_DIR
:
"
devops/gcp/configmap"
OSDU_GCP_HELM_NAMESPACE
:
"
default"
OSDU_GCP_HELM_CONFIG_SERVICE_VARS
:
"
--set
data.log_level=$OSDU_GCP_LOG_LEVEL
--set
data.app_project=$OSDU_GCP_PROJECT
--set
data.app_googleaudience=$GOOGLE_AUDIENCE
--set
data.google_audiences=$GOOGLE_AUDIENCE
--set
data.app_register=$OSDU_GCP_REGISTER_API"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS
:
"
--set
data.image=$CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA
--set
data.serviceAccountName=workload-identity-notification"
OSDU_GCP_HELM_CONFIG_SERVICE
:
"
notification-config"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE
:
"
notification-deploy"
OSDU_GCP_HELM_PACKAGE_CHARTS
:
"
devops/gcp/deploy
devops/gcp/configmap"
AWS_BUILD_SUBDIR
:
provider/notification-aws/build-aws
...
...
@@ -46,8 +47,7 @@ include:
file
:
"
cloud-providers/azure.yml"
-
project
:
"
osdu/platform/ci-cd-pipelines"
ref
:
"
master"
file
:
"
cloud-providers/osdu-gcp-cloudrun.yml"
file
:
"
cloud-providers/osdu-gcp-gke.yml"
-
project
:
"
osdu/platform/ci-cd-pipelines"
file
:
"
cloud-providers/aws.yml"
...
...
@@ -59,4 +59,3 @@ osdu-gcp-test:
variables
:
ENVIRONMENT
:
$OSDU_GCP_ENVIRONMENT
REGISTER_BASE_URL
:
$OSDU_GCP_REGISTER_BASE_URL
allow_failure
:
true
NOTICE
View file @
46c8b516
This diff is collapsed.
Click to expand it.
notification-core/src/main/java/org/opengroup/osdu/notification/errors/SpringExceptionMapper.java
View file @
46c8b516
...
...
@@ -18,6 +18,8 @@ package org.opengroup.osdu.notification.errors;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.Ordered
;
...
...
@@ -32,6 +34,7 @@ import org.springframework.web.context.request.WebRequest;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
javax.validation.ValidationException
;
import
java.io.IOException
;
import
java.nio.file.AccessDeniedException
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -78,6 +81,17 @@ public class SpringExceptionMapper extends ResponseEntityExceptionHandler {
"An unknown error has occurred."
,
e
));
}
@ExceptionHandler
(
IOException
.
class
)
public
ResponseEntity
<
Object
>
handleIOException
(
IOException
e
)
{
if
(
StringUtils
.
containsIgnoreCase
(
ExceptionUtils
.
getRootCauseMessage
(
e
),
"Broken pipe"
))
{
this
.
log
.
warning
(
"Client closed the connection while request still being processed"
);
return
null
;
}
else
{
return
this
.
getErrorResponse
(
new
AppException
(
HttpStatus
.
SERVICE_UNAVAILABLE
.
value
(),
"Unknown error"
,
e
.
getMessage
(),
e
));
}
}
private
ResponseEntity
<
Object
>
getErrorResponse
(
AppException
e
)
{
if
(
e
.
getOriginalException
()!=
null
)
{
this
.
log
.
error
(
e
.
getOriginalException
().
getMessage
(),
e
.
getOriginalException
());
...
...
provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/di/SubscriptionAPIConfigBean.java
0 → 100644
View file @
46c8b516
package
org.opengroup.osdu.notification.provider.azure.di
;
import
lombok.Data
;
import
org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig
;
import
org.opengroup.osdu.notification.provider.interfaces.IAppProperties
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.config.AbstractFactoryBean
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
@Data
@Component
@ConfigurationProperties
public
class
SubscriptionAPIConfigBean
extends
AbstractFactoryBean
<
SubscriptionAPIConfig
>
{
@Autowired
private
IAppProperties
config
;
private
String
apiKey
;
@Override
public
Class
<?>
getObjectType
()
{
return
SubscriptionAPIConfig
.
class
;
}
@Override
protected
SubscriptionAPIConfig
createInstance
()
throws
Exception
{
return
SubscriptionAPIConfig
.
builder
()
.
rootUrl
(
config
.
getRegisterAPI
())
.
apiKey
(
apiKey
)
.
build
();
}
}
provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/di/SubscriptionFactoryAzure.java
0 → 100644
View file @
46c8b516
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.notification.provider.azure.di
;
import
org.opengroup.osdu.core.common.http.IHttpClient
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.notification.ISubscriptionFactory
;
import
org.opengroup.osdu.core.common.notification.ISubscriptionService
;
import
org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig
;
import
org.opengroup.osdu.core.common.notification.SubscriptionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
import
java.util.Objects
;
@Component
@Primary
public
class
SubscriptionFactoryAzure
implements
ISubscriptionFactory
{
private
final
SubscriptionAPIConfig
config
;
private
final
IHttpClient
client
;
@Autowired
public
SubscriptionFactoryAzure
(
final
SubscriptionAPIConfig
subscriptionConfig
,
final
IHttpClient
httpClient
)
{
Objects
.
requireNonNull
(
subscriptionConfig
,
"SubscriptionAPIConfig cannot be null"
);
this
.
config
=
subscriptionConfig
;
this
.
client
=
httpClient
;
}
@Override
public
ISubscriptionService
create
(
final
DpsHeaders
dpsHeaders
)
{
Objects
.
requireNonNull
(
dpsHeaders
,
"headers cannot be null"
);
return
new
SubscriptionService
(
this
.
config
,
this
.
client
,
dpsHeaders
);
}
}
provider/notification-azure/src/test/java/org/opengroup/osdu/notification/di/SubscriptionFactoryAzureTest.java
0 → 100644
View file @
46c8b516
package
org.opengroup.osdu.notification.di
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.notification.ISubscriptionService
;
import
org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig
;
import
org.opengroup.osdu.notification.provider.azure.di.SubscriptionFactoryAzure
;
public
class
SubscriptionFactoryAzureTest
{
@Test
public
void
constructor_should_work_when_config_is_not_null
()
{
SubscriptionAPIConfig
subscriptionAPIConfig
=
SubscriptionAPIConfig
.
builder
().
build
();
subscriptionAPIConfig
.
setApiKey
(
"apiKey"
);
subscriptionAPIConfig
.
setRootUrl
(
"rootUrl"
);
SubscriptionFactoryAzure
subscriptionFactoryAzure
=
new
SubscriptionFactoryAzure
(
subscriptionAPIConfig
,
null
);
Assert
.
assertNotNull
(
subscriptionFactoryAzure
);
}
@Test
(
expected
=
NullPointerException
.
class
)
public
void
constructor_should_throw_npe_if_config_is_null
()
{
SubscriptionFactoryAzure
subscriptionFactoryAzure
=
new
SubscriptionFactoryAzure
(
null
,
null
);
}
@Test
public
void
create_subscriptionService_instance_dpsHeaders_is_not_null
()
{
DpsHeaders
dpsHeaders
=
new
DpsHeaders
();
SubscriptionAPIConfig
subscriptionAPIConfig
=
SubscriptionAPIConfig
.
builder
().
build
();
subscriptionAPIConfig
.
setApiKey
(
"apiKey"
);
subscriptionAPIConfig
.
setRootUrl
(
"rootUrl"
);
SubscriptionFactoryAzure
subscriptionFactoryAzure
=
new
SubscriptionFactoryAzure
(
subscriptionAPIConfig
,
null
);
ISubscriptionService
subscriptionService
=
subscriptionFactoryAzure
.
create
(
dpsHeaders
);
Assert
.
assertNotNull
(
subscriptionService
);
}
@Test
(
expected
=
NullPointerException
.
class
)
public
void
create_subscriptionService_should_throw_npe_if_headers_is_null
()
{
SubscriptionAPIConfig
subscriptionAPIConfig
=
SubscriptionAPIConfig
.
builder
().
build
();
subscriptionAPIConfig
.
setApiKey
(
"apiKey"
);
subscriptionAPIConfig
.
setRootUrl
(
"rootUrl"
);
SubscriptionFactoryAzure
subscriptionFactoryAzure
=
new
SubscriptionFactoryAzure
(
subscriptionAPIConfig
,
null
);
ISubscriptionService
subscriptionService
=
subscriptionFactoryAzure
.
create
(
null
);
}
}
\ No newline at end of file
testing/notification-test-gcp/src/test/resources/logback-test.xml
0 → 100644
View file @
46c8b516
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
%yellow([%thread]) %highlight(| %-5level |) %green(%d) %cyan(| %logger{15} |) %highlight(%msg) %n
</pattern>
<charset>
utf8
</charset>
</encoder>
</appender>
<root
level=
"INFO"
>
<appender-ref
ref=
"CONSOLE"
/>
</root>
</configuration>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment