Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer using CLI over bash scripts to run on Linux based systems and … #13

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions deployment/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
If you want to run the provided WildFly server manually, run with this command:

```bash
$ mvn wildfly:run
$ mvn wildfly:dev
```

And after the WildFly server is started, you can use the `setup-server.sh` to configure the WildFly server to use the JDBC repository for the `batch-jberet` subsystem of WildFly.

## Using the PostgreSQL database as the job repository.

To use the PostgreSQL database as the backend job repository, you need to create the database first. Here are the commands to do so:
Expand All @@ -20,24 +18,13 @@ postgres=# create database batch_db owner batch_user;
CREATE DATABASE
```

And after the WildFly server is started as described above, run the `setup-server-postgresql.sh` script to setup the datasource in WildFly server. Here is the output of the script:

### Using Docker or Podman
```bash
$ ./setup-server-postgrsql.sh
+ JBOSS_HOME=target/wildfly
+ target/wildfly/bin/add-user.sh -u admin -p admin
Updated user 'admin' to file '/Users/weli/works/jberet-examples/deployment/target/wildfly/standalone/configuration/mgmt-users.properties'
+ target/wildfly/bin/jboss-cli.sh -c '--commands=xa-data-source add --name=batch_db --enabled=true --use-java-context=true --use-ccm=true --jndi-name=java:jboss/jsr352/batch_db --xa-datasource-properties={"URL"=>"jdbc:postgresql://localhost:5432/batch_db"} --driver-name=postgresql --password=123 --user-name=batch_user --same-rm-override=false --no-recovery=true, /subsystem=batch-jberet/jdbc-job-repository=batch_db:add(data-source=batch_db), /subsystem=batch-jberet/:write-attribute(name=default-job-repository,value=batch_db)'
{"outcome" => "success"}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
podman run -it -e POSTGRES_PASSWORD=123 -e POSTGRES_USER=batch_user -e POSTGRES_DB=batch_db -p 5432:5432 postgres
```

Then you need to enable the prostrgres profile. This can be done with `-Ppostgres` or `-Dpostgres`.

Here's the console output of from the server:


Expand Down
3 changes: 3 additions & 0 deletions deployment/add-h2-ds.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xa-data-source add --name=batch_db --enabled=true --use-java-context=true --use-ccm=true --jndi-name=java:jboss/jsr352/batch_db --xa-datasource-properties={"URL"=>"jdbc:h2:/tmp/batch_db"} --driver-name=h2 --password=sa --user-name=sa --same-rm-override=false --no-recovery=true
/subsystem=batch-jberet/jdbc-job-repository=batch_db:add(data-source=batch_db)
/subsystem=batch-jberet/:write-attribute(name=default-job-repository, value=batch_db)
3 changes: 3 additions & 0 deletions deployment/add-postgresql-ds.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xa-data-source add --name=batch_db --enabled=true --use-java-context=true --use-ccm=true --jndi-name=java:jboss/jsr352/batch_db --xa-datasource-properties={"URL"=>"jdbc:postgresql://localhost:5432/batch_db"} --driver-name=postgresql --password=123 --user-name=batch_user --same-rm-override=false --no-recovery=true
/subsystem=batch-jberet/jdbc-job-repository=batch_db:add(data-source=batch_db)
/subsystem=batch-jberet/:write-attribute(name=default-job-repository,value=batch_db)
54 changes: 33 additions & 21 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<server.test.feature.pack.groupId>org.wildfly</server.test.feature.pack.groupId>
<version.maven.wildfly.plugin>5.0.1.Final</version.maven.wildfly.plugin>
<version.rest-assured>5.5.0</version.rest-assured>
<wildfly.version>33.0.2.Final</wildfly.version>
<!-- Leave this blank to always use the latest version of WildFly -->
<wildfly.version/>
<configure.ds.script>${project.basedir}/add-h2-ds.cli</configure.ds.script>
</properties>

<dependencies>
Expand Down Expand Up @@ -100,33 +102,28 @@
<groupId>${server.test.feature.pack.groupId}</groupId>
<artifactId>${server.test.feature.pack.artifactId}</artifactId>
<version>${wildfly.version}</version>
<inherit-configs>false</inherit-configs>
<included-configs>
<config>
<model>standalone</model>
<name>standalone-full.xml</name>
</config>
<config>
<model>standalone</model>
<name>standalone.xml</name>
</config>
</included-configs>
<excluded-packages>
<name>docs.schema</name>
<name>appclient</name>
<name>domain</name>
</excluded-packages>
</feature-pack>
<feature-pack>
<location>org.wildfly:wildfly-datasources-galleon-pack:3.0.0.Final</location>
<location>org.wildfly:wildfly-datasources-galleon-pack:8.0.1.Final</location>
</feature-pack>
</feature-packs>
<layers>
<!-- The `postgresql-datasource` layer provides a `PostgreSQLDS` datasource by default.-->
<!-- <layer>postgresql-datasource</layer>-->
<layer>core-tools</layer>
<layer>batch-jberet</layer>
<layer>h2-driver</layer>
<layer>jaxrs-server</layer>
<layer>postgresql-driver</layer>
</layers>
<channels>
<channel>
<manifest>
<groupId>org.wildfly.channels</groupId>
<artifactId>wildfly-ee</artifactId>
<version>${wildfly.version}</version>
</manifest>
</channel>
<channel>
<manifest>
<groupId>org.jberet</groupId>
Expand All @@ -135,6 +132,9 @@
</manifest>
</channel>
</channels>
<scripts>
<script>${configure.ds.script}</script>
</scripts>
</configuration>
<executions>
<execution>
Expand All @@ -149,11 +149,9 @@
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>execute-commands</goal>
<goal>deploy</goal>
</goals>
<configuration>
<filename>batch-deployment.war</filename>
</configuration>
</execution>
<execution>
<phase>post-integration-test</phase>
Expand Down Expand Up @@ -183,4 +181,18 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>postgres</id>
<activation>
<property>
<name>postgres</name>
</property>
</activation>
<properties>
<configure.ds.script>${project.basedir}/add-postgresql-ds.cli</configure.ds.script>
</properties>
</profile>
</profiles>
</project>
12 changes: 0 additions & 12 deletions deployment/setup-server-postgresql.sh

This file was deleted.

13 changes: 0 additions & 13 deletions deployment/setup-server.sh

This file was deleted.