-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solana tests can now be run on an Apple M[1,2,3,4] computer once the …
…steps outlined in src/integration-tests/resources/README.md are followed
- Loading branch information
Showing
8 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM --platform=linux/aarch64 ubuntu:20.04 | ||
|
||
ENV SOLANA_VERSION=1.18.25 | ||
|
||
USER root | ||
|
||
RUN apt-get update && apt-get install -y wget curl | ||
|
||
COPY solana-release-aarch64-unknown-linux-gnu-$SOLANA_VERSION.tar.bz2 /solana-release-aarch64-unknown-linux-gnu-$SOLANA_VERSION.tar.bz2 | ||
|
||
ENV SOLANA_TAR=/solana-release-aarch64-unknown-linux-gnu-$SOLANA_VERSION.tar.bz2 | ||
|
||
RUN tar -xvjf $SOLANA_TAR && rm -f $SOLANA_TAR && mv /home/solana/.local/share/solana/install/releases/$SOLANA_VERSION/bin/* /usr/local/bin/ | ||
|
||
COPY solana-run.sh /usr/bin/solana-run.sh | ||
RUN chmod +x /usr/bin/solana-run.sh | ||
|
||
COPY fetch-spl.sh /usr/bin/fetch-spl.sh | ||
RUN chmod +x /usr/bin/fetch-spl.sh | ||
|
||
ENTRYPOINT ["/usr/bin/solana-run.sh"] |
45 changes: 45 additions & 0 deletions
45
src/integration-test/resources/BuildMeAnAarch64CompliantSolanaDockerImagePleaseDockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM --platform=linux/aarch64 ubuntu:20.04 | ||
|
||
ARG SOLANA_VERSION | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \ | ||
&& apt update \ | ||
&& apt install -y tzdata \ | ||
&& dpkg-reconfigure --frontend noninteractive tzdata \ | ||
&& apt install -y \ | ||
libssl-dev \ | ||
libudev-dev \ | ||
pkg-config \ | ||
zlib1g-dev \ | ||
llvm \ | ||
clang \ | ||
cmake \ | ||
make \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
curl \ | ||
wget \ | ||
git \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
RUN useradd -m -s /bin/bash solana | ||
|
||
USER solana | ||
|
||
WORKDIR /home/solana | ||
|
||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
|
||
ENV PATH="/home/solana/.cargo/bin:${PATH}" | ||
|
||
RUN git clone https://github.com/solana-labs/solana.git --depth 1 --branch v$SOLANA_VERSION /home/solana/solana-src-v$SOLANA_VERSION | ||
|
||
RUN /bin/bash -c "/home/solana/solana-src-v$SOLANA_VERSION/scripts/cargo-install-all.sh /home/solana/.local/share/solana/install/releases/$SOLANA_VERSION" | ||
|
||
RUN tar -cvjf solana-release-aarch64-unknown-linux-gnu-$SOLANA_VERSION.tar.bz2 /home/solana/.local/share/solana/install/ | ||
|
||
CMD ["sleep", "infinity"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#### Why does this README.md exist? | ||
|
||
Well, Solana Labs release multiple different versions of the Solana validator, but they _don't_ release | ||
`solana-release-aarch64-unknown-linux-gnu.tar.bz2`, which is rather irritating. In order | ||
to run a `solana-test-validator` on an `amd64` based architecture, | ||
in particular on an `Apple M[1,2,3,4]` chip, _within_ a `Docker` container, you need it. | ||
|
||
The `Github` runner at `https://github.com/LMAX-Exchange/solana4j` runs on an `x86_64` architecture, so that will remain the default in this project. However, | ||
in the interest that all computer architectures should be treated equally, I have provided a way that you can build your own | ||
image, on a `Apple M[1,2,3,4]` based laptop, and run the integration tests. | ||
|
||
I will not check the artifact into source, but allow the user to generate it themselves and reference the `Aarch64Dockerfile` in `IntegrationTestBase.java`; | ||
be careful to not actually commit these changes, as the pipeline in `Github` will fail. | ||
|
||
```java | ||
SOLANA_VALIDATOR = new GenericContainer<>(new ImageFromDockerfile().withDockerfile(Path.of(MountableFile.forClasspathResource("Aarch64Dockerfile").getFilesystemPath()))) | ||
``` | ||
|
||
In order to build `solana-release-x86_64-unknown-linux-gnu.tar-1.18.25.bz2`, you should run the script `build_aarch64_solana_image.sh`. It will put the artifact exactly where you need | ||
it, if you run the script from `src/integration-test/resources`, as you should. You will need to beef up a lot of resources on | ||
`Docker Desktop`, particularly the `Virtual disk limit`. Running that script and making the above code change, should | ||
be enough to run the integration tests locally on an `Apple M[1,2,3,4]` computer. |
14 changes: 14 additions & 0 deletions
14
src/integration-test/resources/build_aarch64_solana_image.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -xeou pipefail | ||
|
||
trap "docker rm --force solana-aarch64-build-container" EXIT | ||
|
||
solana_version=${1:-1.18.25} | ||
|
||
docker build -t solana-aarch64-build-image -f BuildMeAnAarch64CompliantSolanaDockerImagePleaseDockerfile --build-arg SOLANA_VERSION=$solana_version . | ||
|
||
docker run -d --name solana-aarch64-build-container solana-aarch64-build-image | ||
|
||
docker cp solana-aarch64-build-container:/home/solana/solana-release-aarch64-unknown-linux-gnu-$solana_version.tar.bz2 . | ||
|
||
docker rm --force solana-aarch64-build-container |