schema:
type: string
'423':
- description: RIC is locked
+ description: RIC is not operational
schema:
type: string
deprecated: false
schema:
type: string
'423':
- description: RIC is locked
+ description: RIC is not operational
schema:
type: string
deprecated: false
- name: managedElementId
in: query
description: managedElementId
- required: false
+ required: true
type: string
responses:
'200':
schema:
type: string
'400':
- description: Cannot parse the ServiceRegistrationInfo
+ description: The ServiceRegistrationInfo is not accepted
schema:
type: string
'401':
type: string
deprecated: false
/services/keepalive:
- post:
+ put:
tags:
- Service registry and supervision
summary: Heartbeat from a serice
- operationId: keepAliveServiceUsingPOST
+ operationId: keepAliveServiceUsingPUT
consumes:
- application/json
produces:
private ControllerConfig getControllerConfig(Ric ric) throws ServiceException {
String controllerName = ric.getConfig().controllerName();
if (controllerName.isEmpty()) {
- throw new ServiceException("NO controller configured for RIC: " + ric.name());
+ throw new ServiceException("No controller configured for RIC: " + ric.name());
}
return this.appConfig.getControllerConfig(controllerName);
}
.onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
.doOnNext(ric::setProtocolVersion)
.doOnNext(version -> logger.debug("Established protocol version:{} for Ric: {}", version, ric.name())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from RIC: {}", ric.name())); //
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from RIC: {}", ric.name())) //
+ .onErrorResume(
+ notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.name())));
} else {
return Mono.just(ric.getProtocolVersion());
}
return retrieve(request);
}
+ public Mono<ResponseEntity<String>> putForEntity(String uri) {
+ logger.debug("PUT uri = '{}{}''", baseUrl, uri);
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri);
+ return retrieve(request);
+ }
+
public Mono<String> put(String uri, String body) {
return putForEntity(uri, body) //
.flatMap(this::toBody);
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
value = { //
@ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"),
@ApiResponse(code = 404, message = "The service is not found, needs re-registration")})
- @PostMapping("/services/keepalive")
+ @PutMapping("/services/keepalive")
public ResponseEntity<String> keepAliveService(//
@RequestParam(name = "name", required = true) String serviceName) {
try {
}
private Flux<Object> deleteAllPolicyInstances(Ric ric, Throwable t) {
- logger.warn("Recreation of policies failed for ric: {}, reason: {}", ric.name(), t.getMessage());
+ logger.debug("Recreation of policies failed for ric: {}, reason: {}", ric.name(), t.getMessage());
deleteAllPoliciesInRepository(ric);
Flux<PolicyType> synchronizedTypes = this.a1ClientFactory.createA1Client(ric) //
// Keep alive
url = "/services/keepalive?name=name";
- ResponseEntity<String> entity = restClient().postForEntity(url, null).block();
+ ResponseEntity<String> entity = restClient().putForEntity(url).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
// DELETE service
assertThat(services.size()).isEqualTo(0);
// Keep alive, no registerred service
- testErrorCode(restClient().post("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
+ testErrorCode(restClient().put("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
// PUT servive with bad payload
testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
StepVerifier.create(factoryUnderTest.createA1Client(ric)) //
.expectSubscription() //
- .expectErrorMatches(throwable -> throwable.getMessage().equals(EXCEPTION_MESSAGE)) //
+ .expectError() //
.verify();
- assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Not correct protocol");
+ assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Protocol negotiation failed for " + ric.name());
}
private A1Client createClient(A1ProtocolType version) throws ServiceException {
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;
import java.util.Vector;
+
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.oransc.policyagent.repository.Rics;
import org.oransc.policyagent.repository.Services;
import org.oransc.policyagent.utils.LoggingUtils;
+
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
synchronizerUnderTest.run(RIC_1);
verifyCorrectLogMessage(0, logAppender,
- "Recreation of policies failed for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage);
+ "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage);
verify(a1ClientMock, times(2)).deleteAllPolicies();
verifyNoMoreInteractions(a1ClientMock);
package org.oransc.policyagent.utils;
+import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Vector;
import org.oransc.policyagent.repository.Policy;
import org.oransc.policyagent.repository.PolicyType;
import org.oransc.policyagent.repository.PolicyTypes;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
}
}
+ Mono<String> monoError(String responseBody, HttpStatus status) {
+ byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8);
+ WebClientResponseException a1Exception = new WebClientResponseException(status.value(),
+ status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null);
+ return Mono.error(a1Exception);
+ }
+
@SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests.
private void sleep() {
try {