Skip to content

Commit

Permalink
Merge branch 'ScorpioBroker:development-quarkus' into development-sco…
Browse files Browse the repository at this point in the history
…rpio-v4
  • Loading branch information
MericFeyz authored Jun 28, 2024
2 parents e4716f1 + 97c8a16 commit 7dd6302
Show file tree
Hide file tree
Showing 27 changed files with 4,158 additions and 215 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/fed-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: API Fed test against Java version
on: [push,pull_request]
jobs:
# - name: docker-login
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USER }}
# password: ${{ secrets.DOCKER_TOKEN }}
# - name: docker tag and push
# run: |
# docker tag scorpiobroker/all-in-one-runner:java-kafka-latest scorpiobroker/all-in-one-runner:java-kafka-debugging
# docker push scorpiobroker/all-in-one-runner:java-kafka-debugging
# - name: start docker dist
# run: |
# docker-compose -f ./compose-files/docker-compose-java-dist-kafka-test.yml up &
# sleep 120
# - name: newman action
# uses: matt-ball/newman-action@master
# with:
# collection: api-test.json
# environment: api-test-dist-environment.json
# - name: Stopping Scorpio
# run: docker-compose -f ./compose-files/docker-compose-java-dist-kafka-test.yml down
build-java-aaio:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.22
uses: actions/setup-java@v3
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
- name: Build testserver
run: |
cd testserver
docker build -t testserver .
- name: Build dump request server
run: |
cd dumpreq
docker build -t dumprequest .
- name: Get release number
id: get-id
run: |
id=$(echo ${{github.ref_name}} | cut -d/ -f2)
echo "::set-output name=id::$id"
- name: build-java
run: |
mvn clean package -DskipTests -Din-memory -Pin-memory -Ddocker -Ddocker-tag=java-${{steps.get-id.outputs.id}} -Dos=java -Dquarkus.profile=in-memory
- name: docker tag
run: |
docker tag scorpiobroker/all-in-one-runner:java-${{steps.get-id.outputs.id}} scorpiobroker/all-in-one-runner:java-latest
- name: start docker aaio
run: |
docker-compose -f ./compose-files/docker-compose-java-aaio-fed-test.yml up > dockerout.log &
sleep 120
- name: newman action
uses: matt-ball/newman-action@master
with:
collection: fed-test.json
environment: fed-test-environment.json
- name: Stopping Scorpio
if: always()
run: |
docker-compose -f ./compose-files/docker-compose-java-aaio-fed-test.yml down
- name: print log
if: always()
run: |
cat dockerout.log
- name: docker-login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
# - name: docker tag and push
# run: |
# docker push scorpiobroker/all-in-one-runner:java-${{steps.get-id.outputs.id}}
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,5 @@ public interface NGSIConstants {
NGSI_LD_NOTIFICATION_TRIGGER_ENTITY_CREATED, NGSI_LD_NOTIFICATION_TRIGGER_ENTITY_UPDATED,
NGSI_LD_NOTIFICATION_TRIGGER_ENTITY_DELETED, NGSI_LD_NOTIFICATION_TRIGGER_ATTRIBUTE_CREATED,
NGSI_LD_NOTIFICATION_TRIGGER_ATTRIBUTE_UPDATED, NGSI_LD_NOTIFICATION_TRIGGER_ATTRIBUTE_DELETED);
public static final String CONTEXT_SOURCE_INFO = "contextSourceInfo";
}
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ public static MultiMap getHeadersForRemoteCall(JsonArray headerFromReg, String t
.formatted(result.get(NGSIConstants.JSONLD_CONTEXT));
result.remove(NGSIConstants.JSONLD_CONTEXT).add("Link", linkHeader);
}
result.add("Accept", "application/json");
if(!result.contains("Accept")) {
result.add("Accept", "application/json");
}
if (tenant != null) {
result.add(NGSIConstants.TENANT_HEADER, tenant);
}
Expand Down Expand Up @@ -1107,4 +1109,15 @@ public static Uni<Context> getContext(List<Object> headerContext, JsonLDService
}
return context;
}
public static io.vertx.mutiny.core.MultiMap getHeadToFrwd(io.vertx.mutiny.core.MultiMap remoteHeaders, MultiMap headersFromReq) {
io.vertx.mutiny.core.MultiMap toFrwd = io.vertx.mutiny.core.MultiMap.newInstance(HeadersMultiMap.headers());
for(Entry<String, String> entry: remoteHeaders.entries()){
if(entry.getValue().equals("urn:ngsi-ld:request")){
toFrwd.add(entry.getKey(), headersFromReq.get(entry.getKey()));
}else{
toFrwd.add(entry.getKey(), entry.getValue());
}
}
return toFrwd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Uni<RestResponse<Object>> createMultiple(HttpServerRequest request,
if(expandedEntities.isEmpty()){
return Uni.createFrom().item(fails).onItem().transform(HttpUtils::generateBatchResult);
}
return entityService.createBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly)
return entityService.createBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly,request.headers())
.onItem().transform(opResults -> {
opResults.addAll(fails);
return HttpUtils.generateBatchResult(opResults);
Expand Down Expand Up @@ -169,7 +169,7 @@ public Uni<RestResponse<Object>> upsertMultiple(HttpServerRequest request,
List<NGSILDOperationResult> fails = tuple.getItem1();
List<Map<String, Object>> expandedEntities = tuple.getItem2();
List<Context> contexts = tuple.getItem3();
return entityService.upsertBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly, doReplace)
return entityService.upsertBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly, doReplace,request.headers())
.onItem().transform(opResults -> {
opResults.addAll(fails);
return HttpUtils.generateBatchResult(opResults);
Expand Down Expand Up @@ -231,7 +231,7 @@ public Uni<RestResponse<Object>> appendMultiple(HttpServerRequest request,
List<NGSILDOperationResult> fails = tuple.getItem1();
List<Map<String, Object>> expandedEntities = tuple.getItem2();
List<Context> contexts = tuple.getItem3();
return entityService.appendBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly,isNoOverwrite)
return entityService.appendBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly,isNoOverwrite,request.headers())
.onItem().transform(opResults -> {
opResults.addAll(fails);
return HttpUtils.generateBatchResult(opResults);
Expand All @@ -250,7 +250,7 @@ public Uni<RestResponse<Object>> deleteMultiple(HttpServerRequest request, Strin
}catch (DecodeException e){
return Uni.createFrom().item(HttpUtils.handleControllerExceptions(e));
}
return entityService.deleteBatch(HttpUtils.getTenant(request), entityIds, localOnly).onItem()
return entityService.deleteBatch(HttpUtils.getTenant(request), entityIds, localOnly,request.headers()).onItem()
.transform(opResults -> {
return HttpUtils.generateBatchResult(opResults);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);
Expand Down Expand Up @@ -298,7 +298,7 @@ public Uni<RestResponse<Object>> mergeMultiple(HttpServerRequest request,
List<NGSILDOperationResult> fails = tuple.getItem1();
List<Map<String, Object>> expandedEntities = tuple.getItem2();
List<Context> contexts = tuple.getItem3();
return entityService.mergeBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly,isNoOverwrite)
return entityService.mergeBatch(HttpUtils.getTenant(request), expandedEntities, contexts, localOnly,isNoOverwrite,request.headers())
.onItem().transform(opResults -> {
opResults.addAll(fails);
return HttpUtils.generateBatchResult(opResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Uni<RestResponse<Object>> createEntity(HttpServerRequest req, String body
return HttpUtils.expandBody(req, body, AppConstants.ENTITY_CREATE_PAYLOAD, ldService).onItem()
.transformToUni(tuple -> {
logger.debug("creating entity");
return entityService.createEntity(HttpUtils.getTenant(req), tuple.getItem2(), tuple.getItem1())
return entityService.createEntity(HttpUtils.getTenant(req), tuple.getItem2(), tuple.getItem1(),req.headers())
.onItem().transform(opResult -> {
logger.debug("Done creating entity");
return HttpUtils.generateCreateResult(opResult, AppConstants.ENTITES_URL);
Expand Down Expand Up @@ -105,7 +105,7 @@ public Uni<RestResponse<Object>> updateEntity(HttpServerRequest req, @PathParam(
.transformToUni(tuple -> {
logger.debug("patch attrs");
return entityService
.updateEntity(HttpUtils.getTenant(req), entityId, tuple.getItem2(), tuple.getItem1())
.updateEntity(HttpUtils.getTenant(req), entityId, tuple.getItem2(), tuple.getItem1(),req.headers())
.onItem().transform(HttpUtils::generateUpdateResultResponse);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public Uni<RestResponse<Object>> appendEntity(HttpServerRequest req, @PathParam(
.transformToUni(tuple -> {
logger.debug("post attrs");
return entityService.appendToEntity(HttpUtils.getTenant(req), entityId, tuple.getItem2(),
noOverwrite, tuple.getItem1()).onItem().transform(HttpUtils::generateUpdateResultResponse);
noOverwrite, tuple.getItem1(),req.headers()).onItem().transform(HttpUtils::generateUpdateResultResponse);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);

}
Expand Down Expand Up @@ -168,7 +168,7 @@ public Uni<RestResponse<Object>> partialUpdateAttribute(HttpServerRequest req,
String expAttrib = tuple.getItem1().expandIri(attrib, false, true, null, null);
logger.debug("update entry :: started");
return entityService.partialUpdateAttribute(HttpUtils.getTenant(req), entityId, expAttrib,
tuple.getItem2(), tuple.getItem1()).onItem().transform(updateResult -> {
tuple.getItem2(), tuple.getItem1(),req.headers()).onItem().transform(updateResult -> {
logger.trace("update entry :: completed");
return HttpUtils.generateUpdateResultResponse(updateResult);
});
Expand Down Expand Up @@ -206,7 +206,7 @@ public Uni<RestResponse<Object>> deleteAttribute(HttpServerRequest request, @Pat
String finalAttrId = context.expandIri(attrId, false, true, null, null);
logger.trace("delete attribute :: started");
return entityService
.deleteAttribute(HttpUtils.getTenant(request), entityId, finalAttrId, datasetId, deleteAll, context)
.deleteAttribute(HttpUtils.getTenant(request), entityId, finalAttrId, datasetId, deleteAll, context,request.headers())
.onItem().transform(opResult -> {
logger.trace("delete attribute :: completed");
return HttpUtils.generateDeleteResult(opResult);
Expand All @@ -232,7 +232,7 @@ public Uni<RestResponse<Object>> deleteEntity(HttpServerRequest request, @PathPa
return Uni.createFrom().item(HttpUtils.handleControllerExceptions(e));
}
return ldService.parse(HttpUtils.getAtContext(request)).onItem().transformToUni(context -> {
return entityService.deleteEntity(HttpUtils.getTenant(request), entityId, context).onItem()
return entityService.deleteEntity(HttpUtils.getTenant(request), entityId, context,request.headers()).onItem()
.transform(HttpUtils::generateDeleteResult);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);

Expand All @@ -259,7 +259,7 @@ public Uni<RestResponse<Object>> mergePatch(HttpServerRequest request, @PathPara
return HttpUtils.expandBody(request, body, AppConstants.MERGE_PATCH_REQUEST, ldService).onItem()
.transformToUni(tuple -> {
return entityService
.mergePatch(HttpUtils.getTenant(request), entityId, tuple.getItem2(), tuple.getItem1())
.mergePatch(HttpUtils.getTenant(request), entityId, tuple.getItem2(), tuple.getItem1(),request.headers())
.onItem().transform(HttpUtils::generateUpdateResultResponse);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);

Expand Down Expand Up @@ -287,7 +287,7 @@ public Uni<RestResponse<Object>> replaceEntity(@PathParam("entityId") String ent
return HttpUtils.expandBody(request, body, AppConstants.REPLACE_ENTITY_PAYLOAD, ldService).onItem()
.transformToUni(tuple -> {

return entityService.replaceEntity(HttpUtils.getTenant(request), tuple.getItem2(), tuple.getItem1())
return entityService.replaceEntity(HttpUtils.getTenant(request), tuple.getItem2(), tuple.getItem1(),request.headers())
.onItem().transform(opResult -> {

logger.debug("Done replacing entity");
Expand All @@ -314,7 +314,7 @@ public Uni<RestResponse<Object>> replaceAttribute(@PathParam("attrId") String at
.transformToUni(tuple -> {
String finalAttrId = tuple.getItem1().expandIri(attrId, false, true, null, null);
return entityService.replaceAttribute(HttpUtils.getTenant(request), tuple.getItem2(),
tuple.getItem1(), entityId, finalAttrId).onItem().transform(opResult -> {
tuple.getItem1(), entityId, finalAttrId,request.headers()).onItem().transform(opResult -> {
logger.debug("Done replacing attribute");
return HttpUtils.generateUpdateResultResponse(opResult);
}).onFailure().recoverWithItem(HttpUtils::handleControllerExceptions);
Expand Down
Loading

0 comments on commit 7dd6302

Please sign in to comment.