diff options
author | Lee Anjella Macabuhay <lee.anjella.macabuhay@est.tech> | 2025-01-17 13:33:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2025-01-17 13:33:37 +0000 |
commit | 4c569dc127bff04f4ae83b11a1f0c75b44655c62 (patch) | |
tree | 1227bcc857fad184a275c7accac37c182414ead6 /cps-ncmp-service | |
parent | 76a3bddc4494b6856084b02f49e37e7ab7c5d27a (diff) | |
parent | 05580253e6d2c7c997aead716a93ee5e7f6db0d9 (diff) |
Merge "Make Response Timeout Configurable in WebClient Configuration"
Diffstat (limited to 'cps-ncmp-service')
4 files changed, 10 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/ServiceConfig.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/ServiceConfig.java index f1fce0c7c6..775e9d7b14 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/ServiceConfig.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/ServiceConfig.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation. + * Copyright (C) 2024-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,4 +33,5 @@ public abstract class ServiceConfig { private Integer connectionTimeoutInSeconds = 1; private long readTimeoutInSeconds = 1; private long writeTimeoutInSeconds = 1; + private long responseTimeoutInSeconds = 60; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java index eefabd1079..0214c0c2a9 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation. + * Copyright (C) 2024-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,6 @@ import reactor.netty.resources.ConnectionProvider; */ public class WebClientConfiguration { - private static final Duration DEFAULT_RESPONSE_TIMEOUT = Duration.ofSeconds(30); - protected WebClient configureWebClient(final WebClient.Builder webClientBuilder, final ServiceConfig serviceConfig) { final ConnectionProvider connectionProvider = getConnectionProvider(serviceConfig); @@ -53,7 +51,7 @@ public class WebClientConfiguration { private static HttpClient createHttpClient(final ServiceConfig serviceConfig, final ConnectionProvider connectionProvider) { return HttpClient.create(connectionProvider) - .responseTimeout(DEFAULT_RESPONSE_TIMEOUT) + .responseTimeout(Duration.ofSeconds(serviceConfig.getResponseTimeoutInSeconds())) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, serviceConfig.getConnectionTimeoutInSeconds() * 1000) .doOnConnected(connection -> connection.addHandlerLast(new ReadTimeoutHandler( serviceConfig.getReadTimeoutInSeconds(), TimeUnit.SECONDS)).addHandlerLast( diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy index 23f5edd890..387252e163 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation. + * Copyright (C) 2023-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ class DmiHttpClientConfigSpec extends Specification { assert connectionTimeoutInSeconds == 4 assert readTimeoutInSeconds == 5 assert writeTimeoutInSeconds == 6 + assert responseTimeoutInSeconds == 60 } } @@ -56,6 +57,7 @@ class DmiHttpClientConfigSpec extends Specification { assert connectionTimeoutInSeconds == 14 assert readTimeoutInSeconds == 15 assert writeTimeoutInSeconds == 16 + assert responseTimeoutInSeconds == 60 } } @@ -68,6 +70,7 @@ class DmiHttpClientConfigSpec extends Specification { assert connectionTimeoutInSeconds == 24 assert readTimeoutInSeconds == 25 assert writeTimeoutInSeconds == 26 + assert responseTimeoutInSeconds == 60 } } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy index b988f9e171..3df910322c 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation. + * Copyright (C) 2024-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ class PolicyExecutorHttpClientConfigSpec extends Specification { assert pendingAcquireMaxCount == 33 assert connectionTimeoutInSeconds == 34 assert writeTimeoutInSeconds == 36 + assert responseTimeoutInSeconds == 60 } } |