Skip to content

Commit 2e27bdd

Browse files
EricWittmannmatthyx
andauthoredDec 8, 2022
Support for SQL Server (by matthyx) (#3013)
* Add support for SQL Server database * Added storage test for mssql. Fixed some issues found. Test not yet passing. * Indicate the docker image tag to use for the mssql test container * remove ON CONFLICT from mssql statements (#3002) * Enabled additional mssql tests. Fixed a few issues with the mssql support * Why is the makefile not working? * Fix spaces vs. tabs * Removed temporary snapshot of the maven-plugin Co-authored-by: Matthias Bertschy <matthias.bertschy@gmail.com>
1 parent 4c43e6d commit 2e27bdd

File tree

30 files changed

+991
-85
lines changed

30 files changed

+991
-85
lines changed
 

‎CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ Also don't forget the documentation (reference documentation, javadoc...).
7272
Be sure to test your pull request using all storage variants:
7373

7474
1. SQL storage (using the `-Psql` profile)
75-
2. KafkaSQL storage (using the `-Pkafkasql` profile)
75+
2. SQL Server storage (using the `-Pmssql` profile)
76+
3. KafkaSQL storage (using the `-Pkafkasql` profile)
7677

7778
### Customizing Registry supported ArtifactTypes
7879

‎Makefile

+71-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# used for mem, sql & kafkasql.
1+
# used for mem, sql, mssql & kafkasql.
22
# 'override' keyword prevents the variable from being overrideen
33
override DOCKERFILE_LOCATION := ./distro/docker/target/docker
44

55
MEM_DOCKERFILE ?= Dockerfile.jvm
66
SQL_DOCKERFILE ?= Dockerfile.sql.jvm
7+
MSSQL_DOCKERFILE ?= Dockerfile.mssql.jvm
78
KAFKASQL_DOCKERFILE ?= Dockerfile.kafkasql.jvm
89
DOCKER_BUILD_WORKSPACE ?= $(DOCKERFILE_LOCATION)
910

@@ -53,7 +54,7 @@ build-all:
5354
@echo "----------------------------------------------------------------------"
5455
@echo " Building All Modules "
5556
@echo "----------------------------------------------------------------------"
56-
./mvnw -T 1.5C clean install -Pprod -Psql -Pkafkasql -DskipTests=$(SKIP_TESTS) $(BUILD_FLAGS)
57+
./mvnw -T 1.5C clean install -Pprod -Psql -Pmssql -Pkafkasql -DskipTests=$(SKIP_TESTS) $(BUILD_FLAGS)
5758

5859
.PHONY: build-in-memory ## Builds and test in-memory module. Variables available for override [SKIP_TESTS, BUILD_FLAGS]
5960
build-in-memory:
@@ -175,6 +176,24 @@ push-sql-native-image:
175176
@echo "------------------------------------------------------------------------"
176177
docker push $(IMAGE_REPO)/apicurio/apicurio-registry-sql-native:$(IMAGE_TAG)
177178

179+
.PHONY: build-mssql-image ## Builds docker image for 'mssql' storage variant. Variables available for override [MSSQL_DOCKERFILE, IMAGE_REPO, IMAGE_TAG, DOCKER_BUILD_WORKSPACE]
180+
build-mssql-image:
181+
@echo "------------------------------------------------------------------------"
182+
@echo " Building Image For MSSQL Storage Variant "
183+
@echo " Repository: $(IMAGE_REPO)"
184+
@echo " Tag: $(IMAGE_TAG)"
185+
@echo "------------------------------------------------------------------------"
186+
docker build -f $(DOCKERFILE_LOCATION)/$(MSSQL_DOCKERFILE) -t $(IMAGE_REPO)/apicurio/apicurio-registry-mssql:$(IMAGE_TAG) $(DOCKER_BUILD_WORKSPACE)
187+
188+
.PHONY: push-mssql-image ## Pushes docker image for 'mssql' storage variant. Variables available for override [IMAGE_REPO, IMAGE_TAG]
189+
push-mssql-image:
190+
@echo "------------------------------------------------------------------------"
191+
@echo " Pushing Image For MSSQL Storage Variant"
192+
@echo " Repository: $(IMAGE_REPO)"
193+
@echo " Tag: $(IMAGE_TAG)"
194+
@echo "------------------------------------------------------------------------"
195+
docker push $(IMAGE_REPO)/apicurio/apicurio-registry-mssql:$(IMAGE_TAG)
196+
178197
.PHONY: build-kafkasql-image ## Builds docker image for kafkasql storage variant. Variables available for override [KAFKASQL_DOCKERFILE, IMAGE_REPO, IMAGE_TAG, DOCKER_BUILD_WORKSPACE]
179198
build-kafkasql-image:
180199
@echo "------------------------------------------------------------------------"
@@ -184,7 +203,6 @@ build-kafkasql-image:
184203
@echo "------------------------------------------------------------------------"
185204
docker build -f $(DOCKERFILE_LOCATION)/$(KAFKASQL_DOCKERFILE) -t $(IMAGE_REPO)/apicurio/apicurio-registry-kafkasql:$(IMAGE_TAG) $(DOCKER_BUILD_WORKSPACE)
186205

187-
188206
.PHONY: push-kafkasql-image ## Pushes docker image for 'kafkasql' storage variant. Variables available for override [IMAGE_REPO, IMAGE_TAG]
189207
push-kafkasql-image:
190208
@echo "------------------------------------------------------------------------"
@@ -203,7 +221,6 @@ build-kafkasql-native-image:
203221
@echo "------------------------------------------------------------------------"
204222
docker build -f $(DOCKERFILE_LOCATION)/Dockerfile.native -t $(IMAGE_REPO)/apicurio/apicurio-registry-kafkasql-native:$(IMAGE_TAG) storage/kafkasql
205223

206-
207224
.PHONY: push-kafkasql-native-image ## Pushes native docker image for 'kafkasql' storage variant. Variables available for override [IMAGE_REPO, IMAGE_TAG]
208225
push-kafkasql-native-image:
209226
@echo "------------------------------------------------------------------------"
@@ -214,10 +231,10 @@ push-kafkasql-native-image:
214231
docker push $(IMAGE_REPO)/apicurio/apicurio-registry-kafkasql-native:$(IMAGE_TAG)
215232

216233
.PHONY: build-all-images ## Builds all the Images. Variables available for override [IMAGE_REPO, IMAGE_TAG]
217-
build-all-images: build-mem-image build-sql-image build-kafkasql-image
234+
build-all-images: build-mem-image build-sql-image build-mssql-image build-kafkasql-image
218235

219236
.PHONY: push-all-images ## Pushes all the Images. Variables available for override [IMAGE_REPO, IMAGE_TAG]
220-
push-all-images: push-mem-image push-sql-image push-kafkasql-image
237+
push-all-images: push-mem-image push-sql-image push-mssql-image push-kafkasql-image
221238

222239

223240
.PHONY: mem-multiarch-images ## Builds and pushes multi-arch images for 'in-memory' storage variant. Variables available for override [MEM_DOCKERFILE, IMAGE_REPO, IMAGE_TAG, DOCKER_BUILD_WORKSPACE]
@@ -241,6 +258,15 @@ sql-multiarch-images:
241258
@echo "------------------------------------------------------------------------"
242259
docker buildx build --push -f $(DOCKERFILE_LOCATION)/$(SQL_DOCKERFILE) -t $(IMAGE_REPO)/apicurio/apicurio-registry-sql:$(IMAGE_TAG) --platform $(IMAGE_PLATFORMS) $(DOCKER_BUILD_WORKSPACE)
243260

261+
.PHONY: mssql-multiarch-images ## Builds and pushes multi-arch images for 'mssql' storage variant. Variables available for override [MSSQL_DOCKERFILE, IMAGE_REPO, IMAGE_TAG, DOCKER_BUILD_WORKSPACE]
262+
mssql-multiarch-images:
263+
@echo "------------------------------------------------------------------------"
264+
@echo " Building Multi-arch Images For SQL Server Storage Variant "
265+
@echo " Supported Platforms: $(IMAGE_PLATFORMS)"
266+
@echo " Repository: $(IMAGE_REPO)"
267+
@echo " Tag: $(IMAGE_TAG)"
268+
@echo "------------------------------------------------------------------------"
269+
docker buildx build --push -f $(DOCKERFILE_LOCATION)/$(MSSQL_DOCKERFILE) -t $(IMAGE_REPO)/apicurio/apicurio-registry-mssql:$(IMAGE_TAG) --platform $(IMAGE_PLATFORMS) $(DOCKER_BUILD_WORKSPACE)
244270

245271
.PHONY: kafkasql-multiarch-images ## Builds and pushes multi-arch images for kafkasql storage variant. Variables available for override [KAFKASQL_DOCKERFILE, IMAGE_REPO, IMAGE_TAG, DOCKER_BUILD_WORKSPACE]
246272
kafkasql-multiarch-images:
@@ -253,7 +279,7 @@ kafkasql-multiarch-images:
253279
docker buildx build --push -f $(DOCKERFILE_LOCATION)/$(KAFKASQL_DOCKERFILE) -t $(IMAGE_REPO)/apicurio/apicurio-registry-kafkasql:$(IMAGE_TAG) --platform $(IMAGE_PLATFORMS) $(DOCKER_BUILD_WORKSPACE)
254280

255281
.PHONY: multiarch-registry-images ## Builds and pushes multi-arch registry images for all variants. Variables available for override [IMAGE_REPO, IMAGE_TAG]
256-
multiarch-registry-images: mem-multiarch-images sql-multiarch-images kafkasql-multiarch-images
282+
multiarch-registry-images: mem-multiarch-images sql-multiarch-images mssql-multiarch-images kafkasql-multiarch-images
257283

258284

259285

@@ -311,6 +337,20 @@ run-sql-clustered-integration-tests: build-integration-tests-common
311337
@echo "----------------------------------------------------------------------"
312338
./mvnw verify -Pintegration-tests -Pclustered -Psql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
313339

340+
.PHONY: run-mssql-integration-tests ## Runs mssql integration tests
341+
run-mssql-integration-tests: build-integration-tests-common
342+
@echo "----------------------------------------------------------------------"
343+
@echo " Running SQL Server Integration Tests "
344+
@echo "----------------------------------------------------------------------"
345+
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Pmssql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
346+
347+
.PHONY: run-mssql-clustered-integration-tests ## Runs mssql clustered integration tests
348+
run-mssql-clustered-integration-tests: build-integration-tests-common
349+
@echo "----------------------------------------------------------------------"
350+
@echo " Running SQL Server clustered Integration Tests "
351+
@echo "----------------------------------------------------------------------"
352+
./mvnw verify -Pintegration-tests -Pclustered -Pmssql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
353+
314354
.PHONY: run-kafkasql-integration-tests ## Runs kafkasql integration tests
315355
run-kafkasql-integration-tests: build-integration-tests-common
316356
@echo "----------------------------------------------------------------------"
@@ -339,6 +379,13 @@ run-sql-migration-integration-tests: build-integration-tests-common
339379
@echo "----------------------------------------------------------------------"
340380
./mvnw verify -Pintegration-tests -Pmigration -Psql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
341381

382+
.PHONY: run-mssql-migration-integration-tests ## Runs mssql migration integration tests
383+
run-mssql-migration-integration-tests: build-integration-tests-common
384+
@echo "----------------------------------------------------------------------"
385+
@echo " Running SQL Server Migration Integration Tests "
386+
@echo "----------------------------------------------------------------------"
387+
./mvnw verify -Pintegration-tests -Pmigration -mssql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
388+
342389
.PHONY: run-kafkasql-migration-integration-tests ## Runs kafkasql migration integration tests
343390
run-kafkasql-migration-integration-tests: build-integration-tests-common
344391
@echo "----------------------------------------------------------------------"
@@ -353,6 +400,13 @@ run-sql-auth-integration-tests: build-integration-tests-common
353400
@echo "----------------------------------------------------------------------"
354401
./mvnw verify -Pintegration-tests -Pauth -Psql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
355402

403+
.PHONY: run-mssql-auth-integration-tests ## Runs mssql auth integration tests
404+
run-mssql-auth-integration-tests: build-integration-tests-common
405+
@echo "----------------------------------------------------------------------"
406+
@echo " Running SQL Server Auth Integration Tests "
407+
@echo "----------------------------------------------------------------------"
408+
./mvnw verify -Pintegration-tests -Pauth -mssql -pl integration-tests/testsuite -Dmaven.javadoc.skip=true --no-transfer-progress
409+
356410
.PHONY: run-kafkasql-auth-integration-tests ## Runs kafkasql auth integration tests
357411
run-kafkasql-auth-integration-tests: build-integration-tests-common
358412
@echo "----------------------------------------------------------------------"
@@ -365,17 +419,24 @@ run-sql-legacy-tests: build-integration-tests-common
365419
@echo "----------------------------------------------------------------------"
366420
@echo " Running SQL Legacy Tests "
367421
@echo "----------------------------------------------------------------------"
368-
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Pkafkasql -pl integration-tests/legacy-tests -Dmaven.javadoc.skip=true --no-transfer-progress
422+
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Psql -pl integration-tests/legacy-tests -Dmaven.javadoc.skip=true --no-transfer-progress
423+
424+
.PHONY: run-mssql-legacy-tests ## Runs mssql legacy tests
425+
run-mssql-legacy-tests: build-integration-tests-common
426+
@echo "----------------------------------------------------------------------"
427+
@echo " Running SQL Server Legacy Tests "
428+
@echo "----------------------------------------------------------------------"
429+
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -mssql -pl integration-tests/legacy-tests -Dmaven.javadoc.skip=true --no-transfer-progress
369430

370431
.PHONY: run-kafkasql-legacy-tests ## Runs kafkasql legacy tests
371432
run-kafkasql-legacy-tests: build-integration-tests-common
372433
@echo "----------------------------------------------------------------------"
373434
@echo " Running KafkaSQL Legacy Tests "
374435
@echo "----------------------------------------------------------------------"
375-
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Psql -pl integration-tests/legacy-tests -Dmaven.javadoc.skip=true --no-transfer-progress
436+
./mvnw verify -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Pkafkasql -pl integration-tests/legacy-tests -Dmaven.javadoc.skip=true --no-transfer-progress
376437

377438
.PHONY: integration-tests ## Runs all integration tests [SKIP_TESTS, BUILD_FLAGS]
378-
integration-tests: build-all build-integration-tests-common run-ui-tests run-sql-integration-tests run-sql-clustered-integration-tests run-kafkasql-integration-tests run-kafkasql-clustered-integration-tests run-multitenancy-integration-tests run-sql-migration-integration-tests run-kafkasql-migration-integration-tests run-sql-auth-integration-tests run-kafkasql-auth-integration-tests run-sql-legacy-tests run-kafkasql-legacy-tests
439+
integration-tests: build-all build-integration-tests-common run-ui-tests run-sql-integration-tests run-sql-clustered-integration-tests run-mssql-integration-tests run-mssql-clustered-integration-tests run-kafkasql-integration-tests run-kafkasql-clustered-integration-tests run-multitenancy-integration-tests run-sql-migration-integration-tests run-mssql-migration-integration-tests run-kafkasql-migration-integration-tests run-sql-auth-integration-tests run-mssql-auth-integration-tests run-kafkasql-auth-integration-tests run-sql-legacy-tests run-mssql-legacy-tests run-kafkasql-legacy-tests
379440

380441
# Please declare your targets as .PHONY in the format shown below, so that the 'make help' parses the information correctly.
381442
#

‎README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ This project supports several build configuration options that affect the produc
1212

1313
By default, `mvn clean install` produces an executable JAR with the *dev* Quarkus configuration profile enabled, and *in-memory* persistence implementation.
1414

15-
Apicurio Registry supports 3 persistence implementations:
15+
Apicurio Registry supports 4 persistence implementations:
1616
- In-Memory
1717
- KafkaSQL
18-
- SQL
18+
- PostgreSQL
19+
- SQL Server (community contributed and maintained)
1920

2021
If you enable one, a separate set of artifacts is produced with the persistence implementation available.
2122

@@ -42,6 +43,8 @@ This should result in Quarkus and the in-memory registry starting up, with the u
4243
e.g. a higher logging level.
4344
- `-Psql` enables a build of `storage/sql` module and produces `apicurio-registry-storage-sql-<version>-all.zip`. This artifact uses `H2` driver in *dev* mode,
4445
and `PostgreSQL` driver in *prod* mode.
46+
- `-Pmssql` enables a build of `storage/mssql` module and produces `apicurio-registry-storage-mssql-<version>-all.zip`. This artifact uses `H2` driver in *dev* mode,
47+
and `SQL Server` driver in *prod* mode.
4548
- `-Pkafkasql` enables a build of the `storage/kafkasql` module and produces the `apicurio-registry-storage-kafkasql-<version>-all.zip` artifact.
4649
- `-Pnative` *(experimental)* builds native executables. See [Building a native executable](https://quarkus.io/guides/maven-tooling#building-a-native-executable).
4750
- `-Ddocker` *(experimental)* builds docker images. Make sure that you have the docker service enabled and running.
@@ -53,7 +56,7 @@ The following parameters are available for executable files:
5356

5457
### SQL
5558
- In the *dev* mode, the application expects an H2 server running at `jdbc:h2:tcp://localhost:9123/mem:registry`.
56-
- In the *prod* mode, you have to provide connection configuration for a PostgreSQL server as follows:
59+
- In the *prod* mode, you have to provide connection configuration for a PostgreSQL (or SQL Server) server as follows:
5760

5861
|Option|Command argument|Env. variable|
5962
|---|---|---|
@@ -97,6 +100,7 @@ Hub. There are several docker images to choose from, one for each storage optio
97100

98101
* [apicurio-registry-mem](https://hub.docker.com/r/apicurio/apicurio-registry-mem)
99102
* [apicurio-registry-sql](https://hub.docker.com/r/apicurio/apicurio-registry-sql)
103+
* [apicurio-registry-mssql](https://hub.docker.com/r/apicurio/apicurio-registry-mssql)
100104
* [apicurio-registry-kafkasql](https://hub.docker.com/r/apicurio/apicurio-registry-kafkasql)
101105

102106
Run one of the above docker images like this:

‎TESTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This is the normal mode used when you execute the testsuite. Because Apicurio Re
3333
The configuration is provided via maven profiles. You can find all the available maven profiles [here](integration-tests/testsuite/pom.xml)
3434
When executing the testsuite you normally provide two profiles:
3535
+ test profile (which determines the tests that will be executed), some options are acceptance , multitenancy ,...
36-
+ storage variant to test (which determines the storage backend that will be deployed, and therefore tested), the available options are: inmemory , sql , kafkasql .
36+
+ storage variant to test (which determines the storage backend that will be deployed, and therefore tested), the available options are: inmemory , sql, mssql , kafkasql .
3737

3838
You can find multiple examples of how to run the testsuite in this mode in our [Github Actions Workflows](.github/workflows/integration-tests.yaml)
3939

‎app/pom.xml

+8-7
Original file line numberDiff line numberDiff line change
@@ -354,36 +354,37 @@
354354
<version>${apicurio-common-app-components.version}</version>
355355
<executions>
356356
<execution>
357-
<id>merge-properties</id>
358-
<phase>prepare-package</phase>
357+
<id>merge-test-properties</id>
358+
<phase>process-test-classes</phase>
359359
<goals>
360360
<goal>merge</goal>
361361
</goals>
362362
<configuration>
363-
<output>${project.build.outputDirectory}/application.properties</output>
363+
<output>${project.build.testOutputDirectory}/application.properties</output>
364364
<inputs>
365365
<param>${project.build.outputDirectory}/application.properties</param>
366366
<param>${project.build.outputDirectory}/application-prod.properties</param>
367367
<param>${project.build.outputDirectory}/application-dev.properties</param>
368368
<param>${project.build.outputDirectory}/application-test.properties</param>
369369
</inputs>
370-
<deleteInputs>true</deleteInputs>
370+
<deleteInputs>false</deleteInputs>
371371
</configuration>
372372
</execution>
373373
<execution>
374-
<id>merge-test-properties</id>
375-
<phase>process-test-classes</phase>
374+
<id>merge-properties</id>
375+
<phase>prepare-package</phase>
376376
<goals>
377377
<goal>merge</goal>
378378
</goals>
379379
<configuration>
380-
<output>${project.build.testOutputDirectory}/application.properties</output>
380+
<output>${project.build.outputDirectory}/application.properties</output>
381381
<inputs>
382382
<param>${project.build.outputDirectory}/application.properties</param>
383383
<param>${project.build.outputDirectory}/application-prod.properties</param>
384384
<param>${project.build.outputDirectory}/application-dev.properties</param>
385385
<param>${project.build.outputDirectory}/application-test.properties</param>
386386
</inputs>
387+
<deleteInputs>true</deleteInputs>
387388
</configuration>
388389
</execution>
389390
</executions>

0 commit comments

Comments
 (0)
Please sign in to comment.