Skip to content

Commit df7c577

Browse files
authored
Introduce Registry Core REST API v3 (#4085)
* Introduce Registry Core REST API v3 * Fix data migration/upgrade tests * Temporarily disable data migration integration tests * Run v2 regression tests against v3 server (using legacy v2 API) * Addressed comments from @andreaTP - thanks! * Expand default value for CORS_ALLOWED_ORIGINS a bit
1 parent d69e269 commit df7c577

File tree

132 files changed

+5563
-2816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+5563
-2816
lines changed

.github/workflows/dispatch-openapi.yaml

-25
This file was deleted.

.github/workflows/integration-tests.yaml

+44-6
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
if: failure()
135135
uses: actions/upload-artifact@v1.0.0
136136
with:
137-
name: tests-logs
137+
name: tests-logs-h2
138138
path: artifacts
139139

140140
integration-tests-postgresql:
@@ -179,7 +179,7 @@ jobs:
179179
if: failure()
180180
uses: actions/upload-artifact@v1.0.0
181181
with:
182-
name: tests-logs
182+
name: tests-logs-postgresql
183183
path: artifacts
184184

185185

@@ -225,7 +225,7 @@ jobs:
225225
if: failure()
226226
uses: actions/upload-artifact@v1.0.0
227227
with:
228-
name: tests-logs
228+
name: tests-logs-kafkasql
229229
path: artifacts
230230

231231
integration-tests-ui:
@@ -246,7 +246,7 @@ jobs:
246246
- name: Run UI tests
247247
run: |
248248
echo "Starting Registry App (In Memory)"
249-
docker run -it -p 8080:8080 -d --env CORS_ALLOWED_ORIGINS=* ttl.sh/${{ github.sha }}/apicurio/apicurio-registry:1d
249+
docker run -it -p 8080:8080 -d ttl.sh/${{ github.sha }}/apicurio/apicurio-registry:1d
250250
echo "Starting Registry UI"
251251
docker run -it -p 8888:8080 -d ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-ui:1d
252252
@@ -256,7 +256,7 @@ jobs:
256256
257257
echo "App System Info:"
258258
echo "--"
259-
curl -s http://localhost:8080/apis/registry/v2/system/info
259+
curl -s http://localhost:8080/apis/registry/v3/system/info
260260
echo "--"
261261
echo ""
262262
echo "UI Config Info:"
@@ -293,5 +293,43 @@ jobs:
293293
if: failure()
294294
uses: actions/upload-artifact@v3
295295
with:
296-
name: tests-logs
296+
name: tests-logs-ui
297+
path: artifacts
298+
299+
integration-tests-legacy-v2:
300+
name: Integration Tests Legacy V2
301+
runs-on: ubuntu-20.04
302+
needs: prepare-integration-tests
303+
steps:
304+
- name: Checkout Registry 2.5
305+
uses: actions/checkout@v4
306+
with:
307+
ref: '2.5.x'
308+
path: registry-v2
309+
310+
- name: Set up JDK 17
311+
uses: actions/setup-java@v3
312+
with:
313+
java-version: '17'
314+
distribution: 'temurin'
315+
cache: 'maven'
316+
317+
- name: Run Legacy Integration Tests (Core API v2)
318+
run: |
319+
echo "Starting Registry App (In Memory)"
320+
docker run -it -p 8181:8080 -d ttl.sh/${{ github.sha }}/apicurio/apicurio-registry:1d
321+
cd registry-v2
322+
./mvnw -T 1.5C -Pintegration-tests clean install -DskipTests=true -Dmaven.javadoc.skip=true
323+
cd integration-tests
324+
../mvnw -T 1.5C verify -Pregression -Dmaven.javadoc.skip=true -Dquarkus.http.test-host=localhost -Dquarkus.http.test-port=8181
325+
326+
- name: Collect logs
327+
if: failure()
328+
run: ./.github/scripts/collect_logs.sh
329+
330+
- name: Upload tests logs artifacts
331+
if: failure()
332+
uses: actions/upload-artifact@v1.0.0
333+
with:
334+
name: tests-logs-legacy-v2
297335
path: artifacts

.github/workflows/release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
DOCS_VERSION=$(echo "${{ github.event.inputs.release-version}}" | awk -F '.' '{print $1"."$2".x"}')
7777
7878
sed -i "s/version\:\s.*/version: \'${DOCS_VERSION}\'/g" docs/antora.yml
79-
sed -i "5s/\"version\"\:\s\".*\"/\"version\": \"${DOCS_VERSION}\"/g" app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
79+
sed -i "5s/\"version\"\:\s\".*\"/\"version\": \"${DOCS_VERSION}\"/g" app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json
8080
8181
# take only the major, minor and patch
8282
PYTHON_SDK_VERSION=$(echo "${{ github.event.inputs.release-version}}" | awk -F '.' '{print $1"."$2"."$3}')
@@ -178,7 +178,7 @@ jobs:
178178
DOCS_VERSION=$(echo "${{ github.event.inputs.snapshot-version}}" | awk -F '.' '{print $1"."$2".x"}')
179179
180180
sed -i "s/version\:\s.*/version: \'${DOCS_VERSION}\'/g" docs/antora.yml
181-
sed -i "5s/\"version\"\:\s\".*\"/\"version\": \"${DOCS_VERSION}\"/g" app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
181+
sed -i "5s/\"version\"\:\s\".*\"/\"version\": \"${DOCS_VERSION}\"/g" app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json
182182
183183
# take only the major, minor and patch
184184
PYTHON_SDK_VERSION=$(echo "${{ github.event.inputs.snapshot-version}}" | awk -F '.' '{print $1"."$2"."$3}')

.github/workflows/update-openapi.yaml

+4-11
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,15 @@ jobs:
4040
- name: Copy openapi.json
4141
run: |
4242
cd registry
43-
cp ./common/src/main/resources/META-INF/openapi.json ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
44-
45-
- name: Make copy with Auth info
46-
run: |
47-
cd registry/utils/tools
48-
mvn clean package
49-
mvn exec:java -Dexec.mainClass="io.apicurio.registry.utils.tools.AddOpenApiAuth" -Dexec.args="../../app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json ../../app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi-auth.json"
50-
mvn exec:java -Dexec.mainClass="io.apicurio.registry.utils.tools.TransformOpenApiForClientGen" -Dexec.args="../../app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json ../../app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi-gen.json"
43+
cp ./common/src/main/resources/META-INF/openapi.json ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json
44+
cp ./common/src/main/resources/META-INF/openapi-v2.json ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
5145
5246
- name: Commit Release Version Change
5347
run: |
5448
cd registry
49+
git add ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json
5550
git add ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
56-
git add ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi-auth.json
57-
git add ./app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi-gen.json
58-
git commit -m "Automatically updated the core v2 API OpenAPI definition."
51+
git commit -m "Automatically updated the core API OpenAPI definition."
5952
git push
6053
6154
validate:

.github/workflows/validate-openapi.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Validate OpenAPI schema with Spectral and RHOAS Guidelines (Common)
2626
run: npx rhoasapi lint common/src/main/resources/META-INF/openapi.json
2727
- name: Validate OpenAPI schema with Spectral and RHOAS Guidelines (Final)
28-
run: npx rhoasapi lint app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json
28+
run: npx rhoasapi lint app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json
2929
- name: Cleanup
3030
run: |
3131
rm .spectral.yaml

.github/workflows/verify.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ jobs:
356356
base: main
357357
filters: |
358358
openapi:
359-
- 'app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json'
359+
- 'app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json'
360360
361361
- name: Repository Dispatch
362362
if: steps.changes.outputs.openapi == 'true'
@@ -365,7 +365,7 @@ jobs:
365365
token: ${{ secrets.ACCESS_TOKEN }}
366366
repository: Apicurio/apicurio-registry-client-sdk-${{ matrix.language }}
367367
event-type: on-oas-updated
368-
client-payload: '{"openapi_file_path": "app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json"}'
368+
client-payload: '{"openapi_file_path": "app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v3/openapi.json"}'
369369

370370
# Trigger a deployment workflow in the apicurio-operate-first repository, which will
371371
# deploy the `latest-snapshot` version of registry into the 3scale OpenShift cluster

app/src/main/java/io/apicurio/registry/ccompat/rest/v7/impl/AbstractResource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.apicurio.registry.ccompat.rest.error.ConflictException;
2222
import io.apicurio.registry.ccompat.rest.error.UnprocessableEntityException;
2323
import io.apicurio.registry.content.ContentHandle;
24-
import io.apicurio.registry.rest.v2.beans.ArtifactReference;
24+
import io.apicurio.registry.rest.v3.beans.ArtifactReference;
2525
import io.apicurio.registry.rules.RuleApplicationType;
2626
import io.apicurio.registry.rules.RuleViolationException;
2727
import io.apicurio.registry.rules.RulesService;

app/src/main/java/io/apicurio/registry/limits/RegistryLimitsConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import lombok.ToString;
2222

2323
/**
24-
* NOTE: Follow the naming conventions from {@link io.apicurio.registry.rest.v2.beans.Limits}
24+
* NOTE: Follow the naming conventions from {@link io.apicurio.registry.rest.v3.beans.Limits}
2525
*
2626
* @author Fabian Martinez
2727
*/

app/src/main/java/io/apicurio/registry/rest/RegistryExceptionMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import io.apicurio.registry.ccompat.rest.error.*;
2020
import io.apicurio.registry.ccompat.rest.error.ConflictException;
21-
import io.apicurio.registry.rest.v2.beans.Error;
21+
import io.apicurio.registry.rest.v3.beans.Error;
2222
import io.apicurio.registry.rules.RuleViolationException;
2323
import io.apicurio.registry.services.http.ErrorHttpResponse;
2424
import io.apicurio.registry.services.http.RegistryExceptionMapperService;

app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,8 @@ private ArtifactMetaData createArtifactWithRefs(String groupId, String xRegistry
893893
//Try to resolve the new artifact references and the nested ones (if any)
894894
final Map<String, ContentHandle> resolvedReferences = storage.resolveReferences(referencesAsDtos);
895895

896-
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content, RuleApplicationType.CREATE, references, resolvedReferences);
896+
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content,
897+
RuleApplicationType.CREATE, toV3Refs(references), resolvedReferences);
897898

898899
final String finalArtifactId = artifactId;
899900
EditableArtifactMetaDataDto metaData = getEditableMetaData(artifactName, artifactDescription);
@@ -991,7 +992,8 @@ private VersionMetaData createArtifactVersionWithRefs(String groupId, String art
991992
final Map<String, ContentHandle> resolvedReferences = storage.resolveReferences(referencesAsDtos);
992993

993994
String artifactType = lookupArtifactType(groupId, artifactId);
994-
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content, RuleApplicationType.UPDATE, references, resolvedReferences);
995+
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content,
996+
RuleApplicationType.UPDATE, toV3Refs(references), resolvedReferences);
995997
EditableArtifactMetaDataDto metaData = getEditableMetaData(artifactName, artifactDescription);
996998
ArtifactMetaDataDto amd = storage.updateArtifactWithMetadata(defaultGroupIdToNull(groupId), artifactId, xRegistryVersion, artifactType, content, metaData, referencesAsDtos);
997999
return V2ApiUtil.dtoToVersionMetaData(defaultGroupIdToNull(groupId), artifactId, artifactType, amd);
@@ -1099,7 +1101,8 @@ private ArtifactMetaData updateArtifactInternal(String groupId, String artifactI
10991101

11001102
final Map<String, ContentHandle> resolvedReferences = storage.resolveReferences(referencesAsDtos);
11011103

1102-
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content, RuleApplicationType.UPDATE, references, resolvedReferences);
1104+
rulesService.applyRules(defaultGroupIdToNull(groupId), artifactId, artifactType, content,
1105+
RuleApplicationType.UPDATE, toV3Refs(references), resolvedReferences);
11031106
EditableArtifactMetaDataDto metaData = getEditableMetaData(name, description);
11041107
ArtifactMetaDataDto dto = storage.updateArtifactWithMetadata(defaultGroupIdToNull(groupId), artifactId, version, artifactType, content, metaData, referencesAsDtos);
11051108
return V2ApiUtil.dtoToMetaData(defaultGroupIdToNull(groupId), artifactId, artifactType, dto);
@@ -1125,4 +1128,17 @@ private List<ArtifactReferenceDto> toReferenceDtos(List<ArtifactReference> refer
11251128
.collect(Collectors.toList());
11261129
}
11271130

1131+
private static List<io.apicurio.registry.rest.v3.beans.ArtifactReference> toV3Refs(List<ArtifactReference> references) {
1132+
return references.stream().map(ref -> toV3Ref(ref)).collect(Collectors.toList());
1133+
}
1134+
1135+
private static io.apicurio.registry.rest.v3.beans.ArtifactReference toV3Ref(ArtifactReference reference) {
1136+
return io.apicurio.registry.rest.v3.beans.ArtifactReference.builder()
1137+
.artifactId(reference.getArtifactId())
1138+
.groupId(reference.getGroupId())
1139+
.version(reference.getVersion())
1140+
.name(reference.getName())
1141+
.build();
1142+
}
1143+
11281144
}

0 commit comments

Comments
 (0)