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

Add support for running Oracle locally on Apple ARM64 #5540

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ stream or task and managing its lifecycle.

Clone the repo and type

$ ./mvnw -s settings.xml clean install
$ ./mvnw -s .settings.xml clean install

Looking for more information? Follow this [link](https://github.com/spring-cloud/spring-cloud-dataflow/blob/master/spring-cloud-dataflow-docs/src/main/asciidoc/appendix-building.adoc).

Expand All @@ -87,6 +87,19 @@ For more information please refer to the [Git documentation, Formatting and Whit

----

## Running Locally w/ Oracle
By default, the Dataflow server jar does not include the Oracle database driver dependency.
If you want to use Oracle for development/testing when running locally, you can specify the `local-dev-oracle` Maven profile when building.
The following command will include the Oracle driver dependency in the jar:
```
$ ./mvnw -s .settings.xml clean package -Plocal-dev-oracle
```
You can follow the steps in the [Oracle on Mac ARM64](https://github.com/spring-cloud/spring-cloud-dataflow/wiki/Oracle-on-Mac-ARM64#run-container-in-docker) Wiki to run Oracle XE locally in Docker with Dataflow pointing at it.

> **NOTE:** If you are not running Mac ARM64 just skip the steps related to Homebrew and Colima

----

## Contributing

We welcome contributions! See the [CONTRIBUTING](./CONTRIBUTING.adoc) guide for details.
Expand Down
18 changes: 17 additions & 1 deletion spring-cloud-dataflow-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<oracle-driver-ojdbc8.version>21.9.0.0</oracle-driver-ojdbc8.version>
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<checkstyle.config.location>../src/checkstyle/checkstyle.xml</checkstyle.config.location>
Expand Down Expand Up @@ -127,6 +128,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down Expand Up @@ -179,7 +185,7 @@
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.9.0.0</version>
<version>${oracle-driver-ojdbc8.version}</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -409,5 +415,15 @@
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>local-dev-oracle</id>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a precedent for this technique in PRO for H2 dependency.

<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${oracle-driver-ojdbc8.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,50 @@
*/
package org.springframework.cloud.dataflow.server.db.migration;

import java.util.Locale;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.utility.DockerImageName;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;

import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;

import org.springframework.core.log.LogAccessor;

/**
* Basic database schema and JPA tests for Oracle XE.
*
* @author Corneil du Plessis
* @author Chris Bono
*/
@ExtendWith(SystemStubsExtension.class)
public class OracleSmokeTest extends AbstractSmokeTest {

private static final LogAccessor LOG = new LogAccessor(OracleSmokeTest.class);
onobc marked this conversation as resolved.
Show resolved Hide resolved

private static final String WIKI_LINK = "https://github.com/spring-cloud/spring-cloud-dataflow/wiki/Oracle-on-Mac-ARM64";

@SystemStub
private static EnvironmentVariables ENV_VARS;

@BeforeAll
static void startContainer() {
container = new OracleContainer();
if (runningOnMacArm64()) {
LOG.warn(() -> "You are running on Mac ARM64. If this test fails, make sure Colima is running prior " +
"to test invocation. See " + WIKI_LINK + " for details");
ENV_VARS.set("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE", "/var/run/docker.sock");
ENV_VARS.set("DOCKER_HOST", String.format("unix://%s/.colima/docker.sock", System.getProperty("user.home")));
}
container = new OracleContainer(DockerImageName.parse("gvenzl/oracle-xe")
.withTag("18-slim-faststart"));
container.start();
}

private static boolean runningOnMacArm64() {
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
String osArchitecture = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH);
return osName.contains("mac") && osArchitecture.equals("aarch64");
}
}
Loading