You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+40-23Lines changed: 40 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,26 @@
1
1
This guide describes how to develop and contribute pull requests to this connector. The focus is currently on how to
2
2
develop and test the connector, either via a local install of Confluent Platform or of the regular Kafka distribution.
3
3
4
-
Before beginning, you will need to install Java (either version 8, 11, or 17) and also have a MarkLogic instance
5
-
available. It is recommended to use 11 or 17, as Confluent has deprecated Java 8 support in Confluent 7.x and is
6
-
removing it in Confluent 8.x. See [the Confluent compatibility matrix](https://docs.confluent.io/platform/current/installation/versions-interoperability.html#java)
4
+
Before beginning, you will need to install Java (either version 8, 11, or 17) and also have a MarkLogic instance
5
+
available. It is recommended to use 11 or 17, as Confluent has deprecated Java 8 support in Confluent 7.x and is
6
+
removing it in Confluent 8.x. Additionally, Sonar requires the use of Java 11 or 17.
7
+
See [the Confluent compatibility matrix](https://docs.confluent.io/platform/current/installation/versions-interoperability.html#java)
7
8
for more information. After installing your desired version of Java, ensure that the `JAVA_HOME` environment variable
8
9
points to your Java installation.
9
10
10
11
11
12
# Running the test suite
12
13
13
14
The test suite for the MarkLogic Kafka connector, found at `src/test/resources`, requires that an application first be
14
-
deployed to a MarkLogic instance. This application is deployed via
deployed to a MarkLogic instance. This application is deployed via Docker and [ml-gradle](https://github.com/marklogic-community/ml-gradle).
16
16
17
17
Note that you do not need to install [Gradle](https://gradle.org/) - the `gradlew` program used below will install the
18
18
appropriate version of Gradle if you do not have it installed already.
19
19
20
-
Before deploying, first create `gradle-local.properties`
21
-
if it does not yet exist in the root directory of this project and configure `mlPassword` for your `admin` user - e.g.
22
-
23
-
mlPassword=changeme
24
-
25
-
Then deploy the application:
20
+
Then deploy the application to a MarkLogic Docker container built using a docker-compose file:
26
21
22
+
docker-compose up -d --build
23
+
<Wait 20 to 30 seconds and verify that <http://localhost:8001> shows the MarkLogic admin screen before proceeding.>
27
24
./gradlew -i mlDeploy
28
25
29
26
The application deploys a single REST API app server listening on port 8019; please ensure you have this port available
@@ -38,20 +35,40 @@ Alternatively, you can import this project into an IDE such as IntelliJ and run
38
35
39
36
# Running Sonar code analysis
40
37
41
-
An effort has been started to analyze the codebase with Sonar; this will ideally be done by Jenkins in the near future.
38
+
In order to use SonarQube, you must have used Docker to run this project's `docker-compose.yml` file, and you must
39
+
have those services running.
40
+
41
+
To configure the SonarQube service, perform the following steps:
42
+
43
+
1. Go to http://localhost:9000 .
44
+
2. Login as admin/admin. SonarQube will ask you to change this password; you can choose whatever you want ("password" works).
45
+
3. Click on "Create project manually".
46
+
4. Enter "marklogic-kafka-connector" for the Project Display Name; use that as the Project Key as well.
47
+
5. Enter "master" as the main branch name.
48
+
6. Click on "Next".
49
+
8. Click on "Use the global setting" and then "Create project".
50
+
8. On the "Analysis Method" page, click on "Locally".
51
+
9. In the "Provide a token" panel, click on "Generate". Copy the token.
52
+
10. Update `systemProp.sonar.token=<Replace With Your Sonar Token>` in `gradle.properties` in the root of your project.
53
+
54
+
To run SonarQube, run the following Gradle tasks, which will run all the tests with code coverage and then generate
55
+
a quality report with SonarQube:
56
+
57
+
./gradlew test sonar
58
+
59
+
If you do not update `systemProp.sonar.token` in your `gradle.properties` file, you can specify the token via the
60
+
following:
61
+
62
+
./gradlew test sonar -Dsonar.token=paste your token here
63
+
64
+
When that completes, you can find the results at http://localhost:9000/dashboard?id=marklogic-kafka-connector
42
65
43
-
You can run Sonar code analysis locally by doing the following:
66
+
Click on that link. If it's the first time you've run the report, you'll see all issues. If you've run the report
67
+
before, then SonarQube will show "New Code" by default. That's handy, as you can use that to quickly see any issues
68
+
you've introduced on the feature branch you're working on. You can then click on "Overall Code" to see all issues.
44
69
45
-
1.[Install the latest sonarqube](https://www.sonarsource.com/products/sonarqube/downloads/), either via the zip file
46
-
or via Docker.
47
-
2. If you install sonarqube via a zip file, you'll need to adjust its default config as both it and our kafka-junit tests
48
-
try to use the same port (and we haven't figured out yet how to make kafka-junit use a different port). To do so,
49
-
edit the `./conf/sonar.properties` file in the directory where you unzipped the zip file. Uncomment the
50
-
`sonar.embeddedDatabase.port` property and change the port from 9092 to 9093.
51
-
3. Follow the sonarqube docs for starting sonarqube up, logging in, and setting up a "manual" project in your local
52
-
clone of this repository; make sure you generate a token, which can be set to never expire
53
-
4. Configure `systemProp.sonar.login` in your gradle-local.properties (creating that file in the root of this project if necessary)
54
-
5. Run `./gradlew sonar` or `./gradlew test sonar` if you want code coverage to be reported
70
+
Note that if you only need results on code smells and vulnerabilities, you can repeatedly run `./gradlew sonar`
71
+
without having to re-run the tests.
55
72
56
73
For more assistance with Sonar and Gradle, see the [Sonar Gradle plugin docs](https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner-for-gradle/).
0 commit comments