Compare commits
3 Commits
master
...
fix_tests_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a2dc17f04 | ||
|
|
ba04b92459 | ||
|
|
3c5ec6e103 |
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
@ -1,23 +0,0 @@
|
||||
name: Service CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
- name: Build with Maven
|
||||
run: mvn -e -B test
|
||||
23
.travis.yml
23
.travis.yml
@ -1,23 +1,6 @@
|
||||
language: java
|
||||
|
||||
dist: trusty
|
||||
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
|
||||
install:
|
||||
true
|
||||
|
||||
before_script:
|
||||
- pip install --user codecov
|
||||
|
||||
script:
|
||||
- mvn -U -B -V test --fail-at-end -Dsource.skip=true -Dmaven.javadoc.skip=true
|
||||
|
||||
after_success:
|
||||
- mvn clean test jacoco:report
|
||||
- codecov --build "$TRAVIS_JOB_NUMBER-jdk8"
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_failure: change
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
||||
111
README.md
111
README.md
@ -1,11 +1,11 @@
|
||||
embedded-redis
|
||||
==============
|
||||
|
||||
Redis embedded server for Java integration testing
|
||||
[](https://ci.appveyor.com/project/kstyrc/embedded-redis) Windows
|
||||
|
||||
Fork Notes
|
||||
==============
|
||||
This repository is a fork of https://github.com/ozimov/embedded-redis, which is in turn a fork of https://github.com/kstyrc/embedded-redis. We've updated the embedded Redis binaries to version 7.0.15 so we can write tests that use recent Redis features without imposing dependencies that are not well-encapsulated by a single Maven/Gradle build.
|
||||
[](https://travis-ci.org/kstyrc/embedded-redis) Linux
|
||||
|
||||
Redis embedded server for Java integration testing
|
||||
|
||||
Maven dependency
|
||||
==============
|
||||
@ -13,9 +13,25 @@ Maven dependency
|
||||
Maven Central:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.signal</groupId>
|
||||
<groupId>com.github.kstyrc</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<version>0.6</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Previous releases (before 0.6):
|
||||
```xml
|
||||
<repository>
|
||||
<id>clojars.org</id>
|
||||
<url>http://clojars.org/repo</url>
|
||||
</repository>
|
||||
|
||||
...
|
||||
|
||||
<dependency>
|
||||
<groupId>redis.embedded</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@ -38,11 +54,10 @@ RedisServer redisServer = new RedisServer("/path/to/your/redis", 6379);
|
||||
// 2) given os-independent matrix
|
||||
RedisExecProvider customProvider = RedisExecProvider.defaultProvider()
|
||||
.override(OS.UNIX, "/path/to/unix/redis")
|
||||
.override(OS.UNIX, Architecture.x86_64, "/path/to/unix/redis.x86_64")
|
||||
.override(OS.UNIX, Architecture.arm64, "/path/to/unix/redis.arm64")
|
||||
.override(OS.UNIX, Architecture.x86, "/path/to/unix/redis.i386")
|
||||
.override(OS.MAC_OS_X, Architecture.x86_64, "/path/to/macosx/redis-x86_64")
|
||||
.override(OS.MAC_OS_X, Architecture.arm64, "/path/to/macosx/redis.arm64")
|
||||
.override(OS.WINDOWS, Architecture.x86, "/path/to/windows/redis")
|
||||
.override(OS.Windows, Architecture.x86_64, "/path/to/windows/redis")
|
||||
.override(OS.MAC_OS_X, Architecture.x86, "/path/to/macosx/redis")
|
||||
.override(OS.MAC_OS_X, Architecture.x86_64, "/path/to/macosx/redis")
|
||||
|
||||
RedisServer redisServer = new RedisServer(customProvider, 6379);
|
||||
```
|
||||
@ -62,11 +77,9 @@ Or even create simple redis.conf file from scratch:
|
||||
RedisServer redisServer = RedisServer.builder()
|
||||
.redisExecProvider(customRedisProvider)
|
||||
.port(6379)
|
||||
.setting("bind 127.0.0.1") // good for local development on Windows to prevent security popups
|
||||
.slaveOf("locahost", 6378)
|
||||
.setting("daemonize no")
|
||||
.setting("appendonly no")
|
||||
.setting("maxmemory 128M")
|
||||
.build();
|
||||
```
|
||||
|
||||
@ -140,80 +153,32 @@ second replication group on ```6387, 6379``` and third replication group on ephe
|
||||
Redis version
|
||||
==============
|
||||
|
||||
By default, RedisServer runs an OS-specific executable enclosed in in the `embedded-redis` jar. The jar includes:
|
||||
When not provided with the desired redis executable, RedisServer runs os-dependent executable enclosed in jar. Currently is uses:
|
||||
- Redis 2.8.19 in case of Linux/Unix
|
||||
- Redis 2.8.19 in case of OSX
|
||||
- Redis 2.8.19 in case of Windows: https://github.com/MSOpenTech/redis/releases/tag/win-2.8.19
|
||||
|
||||
- Redis 7.0.15 for Linux/Unix (i386, x86_64 and arm64)
|
||||
- Redis 7.0.15 for macOS (x86_64 and arm64e AKA Apple Silicon)
|
||||
|
||||
The enclosed binaries are built from source from the [`7.0.15` tag](https://github.com/redis/redis/releases/tag/7.0.15) in the official Redis repository. The Linux and Darwin/macOS binaries are statically-linked amd64 and x86 executables built using the [build-server-binaries.sh](src/main/docker/build-server-binaries.sh) script included in this repository at `/src/main/docker`. Windows binaries are not included because Windows is not officially supported by Redis.
|
||||
|
||||
Note: the `build-server-binaries.sh` script attempts to build all of the above noted OS and architectures, which means that it expects the local Docker daemon to support all of them. Docker Desktop on macOS and Windows supports multi-arch builds out of the box; Docker on Linux may require [additional configuration](https://docs.docker.com/buildx/working-with-buildx/).
|
||||
|
||||
Callers may provide a path to a specific `redis-server` executable if needed.
|
||||
However, you should provide RedisServer with redis executable if you need specific version.
|
||||
|
||||
|
||||
License
|
||||
==============
|
||||
Licensed under the Apache License, Version 2.0
|
||||
|
||||
The included Redis binaries are covered by [Redis’s license](https://github.com/redis/redis/blob/4930d19e70c391750479951022e207e19111eb55/COPYING):
|
||||
|
||||
> Copyright (c) 2006-2020, Salvatore Sanfilippo
|
||||
> All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
> * Neither the name of Redis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Contributors
|
||||
==============
|
||||
* Krzysztof Styrc ([@kstyrc](https://github.com/kstyrc))
|
||||
* Piotr Turek ([@turu](https://github.com/turu))
|
||||
* anthonyu ([@anthonyu](https://github.com/anthonyu))
|
||||
* Artem Orobets ([@enisher](https://github.com/enisher))
|
||||
* Sean Simonsen ([@SeanSimonsen](https://github.com/SeanSimonsen))
|
||||
* Rob Winch ([@rwinch](https://github.com/rwinch))
|
||||
* Jon Chambers ([@jchambers](https://github.com/jchambers))
|
||||
* Chris Eager ([@eager](https://github.com/eager))
|
||||
* Krzysztof Styrc ([@kstyrc](http://github.com/kstyrc))
|
||||
* Piotr Turek ([@turu](http://github.com/turu))
|
||||
* anthonyu ([@anthonyu](http://github.com/anthonyu))
|
||||
* Artem Orobets ([@enisher](http://github.com/enisher))
|
||||
* Sean Simonsen ([@SeanSimonsen](http://github.com/SeanSimonsen))
|
||||
* Rob Winch ([@rwinch](http://github.com/rwinch))
|
||||
|
||||
|
||||
Changelog
|
||||
==============
|
||||
|
||||
### 0.9.0
|
||||
* Updated to Redis 7.0.15
|
||||
* Updated Guava to 33
|
||||
* Updated JUnit to 4.13.2
|
||||
|
||||
### 0.8.3
|
||||
* Updated to Redis 6.2.7
|
||||
* Statically link Linux binaries with OpenSSL instead of LibreSSL to avoid `openssl.cnf` incompatibilities
|
||||
|
||||
### 0.8.2
|
||||
* Updated to Redis 6.2.6
|
||||
* Added native support for Apple Silicon (darwin/arm64) and Linux aarch64
|
||||
* Compiled Redis servers with TLS support
|
||||
|
||||
### 0.8.1
|
||||
* Include statically-linked Redis binaries
|
||||
* Update still more dependencies
|
||||
|
||||
### 0.8
|
||||
* Updated to Redis 6.0.5
|
||||
* Dropped support for Windows
|
||||
* Updated to Guava 29
|
||||
|
||||
### 0.7
|
||||
* Updated dependencies
|
||||
* Fixed an incorrect maximum memory setting
|
||||
* Add support for more Redis versions
|
||||
* Bind to 127.0.0.1 by default
|
||||
* Clean up gracefully at JVM exit
|
||||
|
||||
### 0.6
|
||||
* Support JDK 6 +
|
||||
|
||||
|
||||
27
appveyor.yml
Normal file
27
appveyor.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: '{build}'
|
||||
os: Windows Server 2012
|
||||
environment:
|
||||
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
|
||||
install:
|
||||
- ps: |
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
if (!(Test-Path -Path "C:\maven" )) {
|
||||
(new-object System.Net.WebClient).DownloadFile(
|
||||
'http://www.us.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip',
|
||||
'C:\maven-bin.zip'
|
||||
)
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
|
||||
}
|
||||
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
|
||||
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
|
||||
- cmd: mvn --version
|
||||
- cmd: java -version
|
||||
build_script:
|
||||
- mvn clean package -B -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
|
||||
test_script:
|
||||
- mvn clean install --batch-mode -Pqulice
|
||||
cache:
|
||||
- C:\maven\
|
||||
- C:\Users\appveyor\.m2
|
||||
|
||||
253
pom.xml
253
pom.xml
@ -1,13 +1,13 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.signal</groupId>
|
||||
<groupId>com.github.kstyrc</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.9.2-SNAPSHOT</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
<name>embedded-redis</name>
|
||||
<description>Redis embedded server for Java integration testing.</description>
|
||||
<url>https://github.com/signalapp/embedded-redis</url>
|
||||
<description>Redis embedded server for Java integration testing</description>
|
||||
<url>https://github.com/kstyrc/embedded-redis</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@ -18,16 +18,16 @@
|
||||
</licenses>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/signalapp/embedded-redis</url>
|
||||
<connection>scm:git:https://github.com/signalapp/embedded-redis.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:signalapp/embedded-redis.git</developerConnection>
|
||||
<tag>0.9.1</tag>
|
||||
</scm>
|
||||
<url>https://github.com/kstyrc/embedded-redis</url>
|
||||
<connection>scm:git:https://github.com/kstyrc/embedded-redis.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/kstyrc/embedded-redis.git</developerConnection>
|
||||
<tag>embedded-redis-0.5</tag>
|
||||
</scm>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Jon Chambers</name>
|
||||
<email>jon@signal.org</email>
|
||||
<name>Krzysztof Styrc</name>
|
||||
<email>kstyrc@gmail.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
@ -35,180 +35,147 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.0.0-jre</version>
|
||||
<version>18.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.17.0</version>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- TEST DEPENDENCIES -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.10.2</version>
|
||||
<version>2.6.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
<version>1.4.1.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.build.directory}/generated-resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<compilerVersion>1.6</compilerVersion>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.13</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-test-certs</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>testResources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/test/bash/tests/tls</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-test-certificates</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./gen-test-certs-if-needed.sh</executable>
|
||||
<workingDirectory>${project.basedir}/src/test/bash</workingDirectory>
|
||||
<arguments>
|
||||
<argument>${project.build.testOutputDirectory}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>cleanup-test-certificates</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./cleanup-test-certs.sh</executable>
|
||||
<workingDirectory>${project.basedir}/src/test/bash</workingDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
||||
2
src/main/docker/.gitignore
vendored
2
src/main/docker/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
redis-server-*
|
||||
redis-*
|
||||
@ -1,18 +0,0 @@
|
||||
ARG ALPINE_VERSION=3.19.1
|
||||
FROM alpine:${ALPINE_VERSION}
|
||||
RUN apk add --no-cache gcc musl-dev openssl-dev openssl-libs-static make pkgconfig linux-headers
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
ARG REDIS_VERSION
|
||||
ENV REDIS_VERSION=${REDIS_VERSION}
|
||||
COPY redis-${REDIS_VERSION}.tar.gz /redis-${REDIS_VERSION}.tar.gz
|
||||
RUN ls -l /
|
||||
|
||||
ARG ARCH
|
||||
RUN tar zxf /redis-${REDIS_VERSION}.tar.gz && \
|
||||
cd redis-${REDIS_VERSION} && \
|
||||
make BUILD_TLS='yes' CC='gcc -static' LDFLAGS='-s' MALLOC='libc' && \
|
||||
mv src/redis-server /build/redis-server-${REDIS_VERSION}-linux-${ARCH}
|
||||
|
||||
CMD [ "/bin/sh" ]
|
||||
@ -1,139 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
REDIS_VERSION=7.0.15
|
||||
REDIS_TARBALL="redis-${REDIS_VERSION}.tar.gz"
|
||||
REDIS_URL="https://download.redis.io/releases/${REDIS_TARBALL}"
|
||||
|
||||
echo $ARCH
|
||||
|
||||
function copy_openssl_and_remove_dylibs() {
|
||||
# To make macOS builds more portable, we want to statically link OpenSSL,
|
||||
# which is not straightforward. To force static compilation, we copy
|
||||
# the openssl libraries and remove dylibs, forcing static linking
|
||||
OPENSSL_HOME="${1}"
|
||||
ARCH=$2
|
||||
OPENSSL_HOME_COPY="${3}/${ARCH}"
|
||||
|
||||
echo "*** Copying openssl libraries for static linking"
|
||||
cp -RL "${OPENSSL_HOME}" "${OPENSSL_HOME_COPY}"
|
||||
rm -f "${OPENSSL_HOME_COPY}"/lib/*.dylib
|
||||
}
|
||||
|
||||
if [ "$(dirname ${0})" != "." ]; then
|
||||
echo "This script must be run from $(dirname ${0}). \`cd\` there and run again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -f "${REDIS_TARBALL}" ]; then
|
||||
curl -o "${REDIS_TARBALL}" "${REDIS_URL}"
|
||||
fi
|
||||
|
||||
all_linux=0
|
||||
if command -pv docker buildx 2>/dev/null; then
|
||||
for arch in amd64 arm64 386; do
|
||||
builder_name="embedded-redis-builder-$RANDOM"
|
||||
|
||||
docker buildx create \
|
||||
--name "$builder_name" \
|
||||
--platform linux/amd64,linux/arm64,linux/386
|
||||
|
||||
docker buildx use "$builder_name"
|
||||
|
||||
echo "*** Building redis version ${REDIS_VERSION} for linux-${arch}"
|
||||
|
||||
set +e
|
||||
docker buildx build \
|
||||
"--platform=linux/${arch}" \
|
||||
--build-arg "REDIS_VERSION=${REDIS_VERSION}" \
|
||||
--build-arg "ARCH=${arch}" \
|
||||
-t "redis-server-builder-${arch}" \
|
||||
--load \
|
||||
.
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "*** ERROR: could not build for linux-${arch}"
|
||||
continue
|
||||
fi
|
||||
set -e
|
||||
|
||||
docker buildx rm "$builder_name"
|
||||
|
||||
docker run -it --rm \
|
||||
"--platform=linux/${arch}" \
|
||||
-v "$(pwd)/":/mnt \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
"redis-server-builder-${arch}" \
|
||||
sh -c "cp /build/redis-server-${REDIS_VERSION}-linux-${arch} /mnt"
|
||||
|
||||
((all_linux+=1))
|
||||
|
||||
done
|
||||
else
|
||||
echo "*** WARNING: No docker command found or docker does not support buildx. Cannot build for linux."
|
||||
fi
|
||||
|
||||
if [[ "${all_linux}" -lt 3 ]]; then
|
||||
echo "*** WARNING: was not able to build for all linux arches; see above for errors"
|
||||
fi
|
||||
|
||||
# To build for macOS, you must be running this script from a Mac. The script requires that openssl@1.1
|
||||
# be installed via Homebrew.
|
||||
#
|
||||
# To build Redis binaries for both arm64e and x86_64, you'll need to run this script from an arm64e
|
||||
# Mac with _two_ parallel installations of Homebrew (see
|
||||
# https://stackoverflow.com/questions/64951024/how-can-i-run-two-isolated-installations-of-homebrew),
|
||||
# and install openssl@1.1 with each.
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
|
||||
tar zxf "${REDIS_TARBALL}"
|
||||
cd "redis-${REDIS_VERSION}"
|
||||
|
||||
# temporary directory for openssl libraries for static linking.
|
||||
# assumes standard Homebrew openssl install:
|
||||
# - arm64e at /opt/homebrew/opt/openssl@1.1
|
||||
# - x86_64 at /usr/local/opt/openssl@1.1
|
||||
OPENSSL_TEMP=$(mktemp -d /tmp/embedded-redis-darwin-openssl.XXXXX)
|
||||
|
||||
# build for arm64 on apple silicon
|
||||
if arch -arm64e true 2>/dev/null; then
|
||||
if [ -d /opt/homebrew/opt/openssl@1.1 ]; then
|
||||
copy_openssl_and_remove_dylibs /opt/homebrew/opt/openssl@1.1 arm64e "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-arm64e (apple silicon)"
|
||||
make distclean
|
||||
arch -arm64e make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/arm64e"
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-arm64"
|
||||
else
|
||||
echo "*** WARNING: openssl@1.1 not found for darwin-arm64e; skipping build"
|
||||
fi
|
||||
else
|
||||
echo "*** WARNING: could not build for darwin-arm64e; you probably want to do this on an apple silicon device"
|
||||
fi
|
||||
|
||||
# build for x86_64 if we're on apple silicon or a recent macos on x86_64
|
||||
if arch -x86_64 true 2>/dev/null; then
|
||||
if [ -d /usr/local/opt/openssl@1.1 ]; then
|
||||
copy_openssl_and_remove_dylibs /usr/local/opt/openssl@1.1 x86_64 "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-x86_64"
|
||||
make distclean
|
||||
arch -x86_64 make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/x86_64"
|
||||
# x86_64 and amd64 are effectively synonymous; we use amd64 here to match the naming scheme used by Docker builds
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-amd64"
|
||||
else
|
||||
echo "*** WARNING: openssl@1.1 not found for darwin-x86_64; skipping build"
|
||||
fi
|
||||
else
|
||||
echo "*** WARNING: you are on a version of macos that lacks /usr/bin/arch, you probably do not want this"
|
||||
exit 1
|
||||
fi
|
||||
cd ..
|
||||
|
||||
else
|
||||
echo "*** WARNING: Cannot build for macos/darwin on a $(uname -s) host"
|
||||
fi
|
||||
|
||||
ls -l redis-server-*
|
||||
|
||||
echo "*** Moving built binaries to ../resources; you need to handle the rest yourself"
|
||||
mv redis-server-* ../resources/
|
||||
@ -1,6 +1,5 @@
|
||||
package redis.embedded;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import redis.embedded.exceptions.EmbeddedRedisException;
|
||||
|
||||
import java.io.*;
|
||||
@ -10,73 +9,64 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
abstract class AbstractRedisInstance implements Redis {
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
abstract class AbstractRedisInstance implements Redis {
|
||||
protected List<String> args = Collections.emptyList();
|
||||
private volatile boolean active = false;
|
||||
private Process redisProcess;
|
||||
private Process redisProcess;
|
||||
private final int port;
|
||||
private final int tlsPort;
|
||||
|
||||
private ExecutorService executor;
|
||||
|
||||
protected AbstractRedisInstance(int port, int tlsPort) {
|
||||
this.port = port;
|
||||
this.tlsPort = tlsPort;
|
||||
}
|
||||
private final ExecutorService executor = Executors.newFixedThreadPool(2);
|
||||
|
||||
protected AbstractRedisInstance(int port) {
|
||||
this(port, 0);
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void start() throws EmbeddedRedisException {
|
||||
if (active) {
|
||||
throw new EmbeddedRedisException("This redis server instance is already running...");
|
||||
}
|
||||
try {
|
||||
redisProcess = createRedisProcessBuilder().start();
|
||||
installExitHook();
|
||||
logErrors();
|
||||
awaitRedisServerReady();
|
||||
logErrors();
|
||||
active = true;
|
||||
} catch (IOException e) {
|
||||
throw new EmbeddedRedisException("Failed to start Redis instance", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void installExitHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(this::stop, "RedisInstanceCleaner"));
|
||||
}
|
||||
|
||||
private void logErrors() {
|
||||
final InputStream errorStream = redisProcess.getErrorStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream));
|
||||
Runnable printReaderTask = new PrintReaderRunnable(reader);
|
||||
executor = Executors.newSingleThreadExecutor();
|
||||
executor.submit(printReaderTask);
|
||||
Runnable errorStreamGobbler = new StreamGobbler(errorStream, System.err, "");
|
||||
executor.submit(errorStreamGobbler);
|
||||
|
||||
final InputStream inputStream = redisProcess.getInputStream();
|
||||
Runnable inputStreamGobbler = new StreamGobbler(inputStream, System.err, "");
|
||||
executor.submit(inputStreamGobbler);
|
||||
}
|
||||
|
||||
private void awaitRedisServerReady() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(redisProcess.getInputStream()));
|
||||
try {
|
||||
StringBuilder outputStringBuilder = new StringBuilder();
|
||||
String outputLine;
|
||||
do {
|
||||
outputLine = reader.readLine();
|
||||
if (outputLine == null) {
|
||||
// Something is wrong. Stream ended before server was activated.
|
||||
throw new EmbeddedRedisException("Redis server failed to become ready. Check logs for details. Redis process log: " + outputStringBuilder.toString());
|
||||
} else {
|
||||
outputStringBuilder.append("\n");
|
||||
outputStringBuilder.append(outputLine);
|
||||
//Something goes wrong. Stream is ended before server was activated.
|
||||
throw new RuntimeException("Can't start redis server. Check logs for details.");
|
||||
}
|
||||
System.out.println(outputLine);
|
||||
} while (!outputLine.matches(redisReadyPattern()));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader, null);
|
||||
// IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,11 +79,12 @@ abstract class AbstractRedisInstance implements Redis {
|
||||
return pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void stop() throws EmbeddedRedisException {
|
||||
if (active) {
|
||||
if (executor != null && !executor.isShutdown()) {
|
||||
executor.shutdown();
|
||||
}
|
||||
IOUtils.closeQuietly(redisProcess.getInputStream());
|
||||
IOUtils.closeQuietly(redisProcess.getOutputStream());
|
||||
IOUtils.closeQuietly(redisProcess.getErrorStream());
|
||||
redisProcess.destroy();
|
||||
tryWaitFor();
|
||||
active = false;
|
||||
@ -108,37 +99,34 @@ abstract class AbstractRedisInstance implements Redis {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> ports() {
|
||||
return port > 0 ? Collections.singletonList(port) : Collections.emptyList();
|
||||
return Arrays.asList(port);
|
||||
}
|
||||
|
||||
public List<Integer> tlsPorts() {
|
||||
return tlsPort > 0 ? Collections.singletonList(tlsPort) : Collections.emptyList();
|
||||
}
|
||||
private static class StreamGobbler implements Runnable {
|
||||
|
||||
private static class PrintReaderRunnable implements Runnable {
|
||||
private final BufferedReader reader;
|
||||
private final InputStream is;
|
||||
private final PrintStream os;
|
||||
private final String prefix;
|
||||
|
||||
private PrintReaderRunnable(BufferedReader reader) {
|
||||
this.reader = reader;
|
||||
private StreamGobbler(InputStream is, PrintStream os, String prefix) {
|
||||
this.is = is;
|
||||
this.os = os;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
readLines();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void readLines() {
|
||||
try {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line=null;
|
||||
while ( (line = br.readLine()) != null) {
|
||||
os.println(prefix + line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,4 @@ public interface Redis {
|
||||
void stop() throws EmbeddedRedisException;
|
||||
|
||||
List<Integer> ports();
|
||||
|
||||
List<Integer> tlsPorts();
|
||||
}
|
||||
|
||||
@ -59,14 +59,6 @@ public class RedisCluster implements Redis {
|
||||
return ports;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> tlsPorts() {
|
||||
List<Integer> ports = new ArrayList<Integer>();
|
||||
ports.addAll(sentinelTlsPorts());
|
||||
ports.addAll(serverTlsPorts());
|
||||
return ports;
|
||||
}
|
||||
|
||||
public List<Redis> sentinels() {
|
||||
return Lists.newLinkedList(sentinels);
|
||||
}
|
||||
@ -79,14 +71,6 @@ public class RedisCluster implements Redis {
|
||||
return ports;
|
||||
}
|
||||
|
||||
public List<Integer> sentinelTlsPorts() {
|
||||
List<Integer> ports = new ArrayList<Integer>();
|
||||
for(Redis redis : sentinels) {
|
||||
ports.addAll(redis.tlsPorts());
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
|
||||
public List<Redis> servers() {
|
||||
return Lists.newLinkedList(servers);
|
||||
}
|
||||
@ -99,14 +83,6 @@ public class RedisCluster implements Redis {
|
||||
return ports;
|
||||
}
|
||||
|
||||
public List<Integer> serverTlsPorts() {
|
||||
List<Integer> ports = new ArrayList<Integer>();
|
||||
for(Redis redis : servers) {
|
||||
ports.addAll(redis.tlsPorts());
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
|
||||
public static RedisClusterBuilder builder() {
|
||||
return new RedisClusterBuilder();
|
||||
}
|
||||
|
||||
@ -12,26 +12,26 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class RedisExecProvider {
|
||||
|
||||
|
||||
private final Map<OsArchitecture, String> executables = Maps.newHashMap();
|
||||
|
||||
public static final String redisVersion = "7.0.15";
|
||||
|
||||
public static RedisExecProvider defaultProvider() {
|
||||
return new RedisExecProvider();
|
||||
}
|
||||
|
||||
|
||||
private RedisExecProvider() {
|
||||
initExecutables();
|
||||
}
|
||||
|
||||
private void initExecutables() {
|
||||
executables.put(OsArchitecture.UNIX_x86, "redis-server-" + redisVersion + "-linux-386");
|
||||
executables.put(OsArchitecture.UNIX_x86_64, "redis-server-" + redisVersion + "-linux-amd64");
|
||||
executables.put(OsArchitecture.UNIX_arm64, "redis-server-" + redisVersion + "-linux-arm64");
|
||||
executables.put(OsArchitecture.WINDOWS_x86, "redis-server-2.8.19.exe");
|
||||
executables.put(OsArchitecture.WINDOWS_x86_64, "redis-server-2.8.19.exe");
|
||||
|
||||
executables.put(OsArchitecture.MAC_OS_X_x86_64, "redis-server-" + redisVersion + "-darwin-amd64");
|
||||
executables.put(OsArchitecture.MAC_OS_X_arm64, "redis-server-" + redisVersion + "-darwin-arm64");
|
||||
executables.put(OsArchitecture.UNIX_x86, "redis-server-2.8.19");
|
||||
executables.put(OsArchitecture.UNIX_x86_64, "redis-server-2.8.19");
|
||||
|
||||
executables.put(OsArchitecture.MAC_OS_X_x86, "redis-server-2.8.19.app");
|
||||
executables.put(OsArchitecture.MAC_OS_X_x86_64, "redis-server-2.8.19.app");
|
||||
}
|
||||
|
||||
public RedisExecProvider override(OS os, String executable) {
|
||||
@ -47,20 +47,14 @@ public class RedisExecProvider {
|
||||
executables.put(new OsArchitecture(os, arch), executable);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public File get() throws IOException {
|
||||
OsArchitecture osArch = OsArchitecture.detect();
|
||||
|
||||
if (!executables.containsKey(osArch)) {
|
||||
throw new IllegalArgumentException("No Redis executable found for " + osArch);
|
||||
}
|
||||
|
||||
String executablePath = executables.get(osArch);
|
||||
|
||||
return fileExists(executablePath) ?
|
||||
return fileExists(executablePath) ?
|
||||
new File(executablePath) :
|
||||
JarUtil.extractExecutableFromJar(executablePath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean fileExists(String executablePath) {
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RedisSentinel extends AbstractRedisInstance {
|
||||
private static final String REDIS_READY_PATTERN = ".*Sentinel (runid|ID) is.*";
|
||||
private static final String REDIS_READY_PATTERN = ".*Sentinel runid is.*";
|
||||
|
||||
public RedisSentinel(List<String> args, int port) {
|
||||
super(port);
|
||||
|
||||
@ -7,7 +7,6 @@ import redis.embedded.exceptions.RedisBuildingException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -22,7 +21,6 @@ public class RedisSentinelBuilder {
|
||||
|
||||
private File executable;
|
||||
private RedisExecProvider redisExecProvider = RedisExecProvider.defaultProvider();
|
||||
private String bind="127.0.0.1";
|
||||
private Integer port = 26379;
|
||||
private int masterPort = 6379;
|
||||
private String masterName = "mymaster";
|
||||
@ -39,11 +37,6 @@ public class RedisSentinelBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisSentinelBuilder bind(String bind) {
|
||||
this.bind = bind;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisSentinelBuilder port(Integer port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
@ -134,13 +127,12 @@ public class RedisSentinelBuilder {
|
||||
if (redisConfigBuilder == null) {
|
||||
addDefaultReplicationGroup();
|
||||
}
|
||||
setting("bind "+bind);
|
||||
setting(String.format(PORT_LINE, port));
|
||||
final String configString = redisConfigBuilder.toString();
|
||||
|
||||
File redisConfigFile = File.createTempFile(resolveConfigName(), ".conf");
|
||||
redisConfigFile.deleteOnExit();
|
||||
Files.asCharSink(redisConfigFile, StandardCharsets.UTF_8).write(configString);
|
||||
Files.write(configString, redisConfigFile, Charset.forName("UTF-8"));
|
||||
sentinelConf = redisConfigFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
@ -7,24 +7,23 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class RedisServer extends AbstractRedisInstance {
|
||||
private static final String REDIS_READY_PATTERN = ".*(R|r)eady to accept connections.*";
|
||||
private static final String REDIS_READY_PATTERN = ".*The server is now ready to accept connections on port.*";
|
||||
private static final int DEFAULT_REDIS_PORT = 6379;
|
||||
|
||||
public RedisServer() {
|
||||
public RedisServer() throws IOException {
|
||||
this(DEFAULT_REDIS_PORT);
|
||||
}
|
||||
|
||||
public RedisServer(int port) {
|
||||
public RedisServer(Integer port) throws IOException {
|
||||
super(port);
|
||||
this.args = builder().port(port).build().args;
|
||||
File executable = RedisExecProvider.defaultProvider().get();
|
||||
this.args = Arrays.asList(
|
||||
executable.getAbsolutePath(),
|
||||
"--port", Integer.toString(port)
|
||||
);
|
||||
}
|
||||
|
||||
public RedisServer(int port, int tlsPort) {
|
||||
super(port, tlsPort);
|
||||
this.args = builder().port(port).tlsPort(tlsPort).build().args;
|
||||
}
|
||||
|
||||
public RedisServer(File executable, int port) {
|
||||
public RedisServer(File executable, Integer port) {
|
||||
super(port);
|
||||
this.args = Arrays.asList(
|
||||
executable.getAbsolutePath(),
|
||||
@ -32,7 +31,7 @@ public class RedisServer extends AbstractRedisInstance {
|
||||
);
|
||||
}
|
||||
|
||||
public RedisServer(RedisExecProvider redisExecProvider, int port) throws IOException {
|
||||
public RedisServer(RedisExecProvider redisExecProvider, Integer port) throws IOException {
|
||||
super(port);
|
||||
this.args = Arrays.asList(
|
||||
redisExecProvider.get().getAbsolutePath(),
|
||||
@ -40,9 +39,9 @@ public class RedisServer extends AbstractRedisInstance {
|
||||
);
|
||||
}
|
||||
|
||||
RedisServer(List<String> args, int port, int tlsPort) {
|
||||
super(port, tlsPort);
|
||||
this.args = new ArrayList<>(args);
|
||||
RedisServer(List<String> args, int port) {
|
||||
super(port);
|
||||
this.args = new ArrayList<String>(args);
|
||||
}
|
||||
|
||||
public static RedisServerBuilder builder() {
|
||||
|
||||
@ -8,7 +8,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -18,9 +17,7 @@ public class RedisServerBuilder {
|
||||
|
||||
private File executable;
|
||||
private RedisExecProvider redisExecProvider = RedisExecProvider.defaultProvider();
|
||||
private String bind="127.0.0.1";
|
||||
private int port = 6379;
|
||||
private int tlsPort = 0;
|
||||
private Integer port = 6379;
|
||||
private InetSocketAddress slaveOf;
|
||||
private String redisConf;
|
||||
|
||||
@ -30,23 +27,13 @@ public class RedisServerBuilder {
|
||||
this.redisExecProvider = redisExecProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisServerBuilder bind(String bind) {
|
||||
this.bind = bind;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisServerBuilder port(int port) {
|
||||
|
||||
public RedisServerBuilder port(Integer port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisServerBuilder tlsPort(int tlsPort) {
|
||||
this.tlsPort = tlsPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisServerBuilder slaveOf(String hostname, int port) {
|
||||
public RedisServerBuilder slaveOf(String hostname, Integer port) {
|
||||
this.slaveOf = new InetSocketAddress(hostname, port);
|
||||
return this;
|
||||
}
|
||||
@ -79,10 +66,9 @@ public class RedisServerBuilder {
|
||||
}
|
||||
|
||||
public RedisServer build() {
|
||||
setting("bind "+bind);
|
||||
tryResolveConfAndExec();
|
||||
List<String> args = buildCommandArgs();
|
||||
return new RedisServer(args, port, tlsPort);
|
||||
return new RedisServer(args, port);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
@ -104,7 +90,7 @@ public class RedisServerBuilder {
|
||||
if (redisConf == null && redisConfigBuilder != null) {
|
||||
File redisConfigFile = File.createTempFile(resolveConfigName(), ".conf");
|
||||
redisConfigFile.deleteOnExit();
|
||||
Files.asCharSink(redisConfigFile, StandardCharsets.UTF_8).write(redisConfigBuilder.toString());
|
||||
Files.write(redisConfigBuilder.toString(), redisConfigFile, Charset.forName("UTF-8"));
|
||||
redisConf = redisConfigFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
@ -127,12 +113,9 @@ public class RedisServerBuilder {
|
||||
args.add(redisConf);
|
||||
}
|
||||
|
||||
args.add("--port");
|
||||
args.add(Integer.toString(port));
|
||||
|
||||
if (tlsPort > 0) {
|
||||
args.add("--tls-port");
|
||||
args.add(Integer.toString(tlsPort));
|
||||
if (port != null) {
|
||||
args.add("--port");
|
||||
args.add(Integer.toString(port));
|
||||
}
|
||||
|
||||
if (slaveOf != null) {
|
||||
|
||||
@ -2,6 +2,5 @@ package redis.embedded.util;
|
||||
|
||||
public enum Architecture {
|
||||
x86,
|
||||
x86_64,
|
||||
arm64
|
||||
x86_64
|
||||
}
|
||||
|
||||
@ -10,20 +10,14 @@ import java.io.IOException;
|
||||
public class JarUtil {
|
||||
|
||||
public static File extractExecutableFromJar(String executable) throws IOException {
|
||||
File command = extractFileFromJar(executable);
|
||||
File tmpDir = Files.createTempDir();
|
||||
tmpDir.deleteOnExit();
|
||||
|
||||
File command = new File(tmpDir, executable);
|
||||
FileUtils.copyURLToFile(Resources.getResource(executable), command);
|
||||
command.deleteOnExit();
|
||||
command.setExecutable(true);
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
public static File extractFileFromJar(String path) throws IOException {
|
||||
File tmpDir = Files.createTempDir();
|
||||
tmpDir.deleteOnExit();
|
||||
|
||||
File file = new File(tmpDir, path);
|
||||
FileUtils.copyURLToFile(Resources.getResource(path), file);
|
||||
file.deleteOnExit();
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,46 +47,58 @@ public class OSDetector {
|
||||
}
|
||||
|
||||
private static Architecture getUnixArchitecture() {
|
||||
BufferedReader input = null;
|
||||
try {
|
||||
String line;
|
||||
Process proc = Runtime.getRuntime().exec("uname -m");
|
||||
try (BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
|
||||
String machine = input.readLine();
|
||||
switch (machine) {
|
||||
case "aarch64":
|
||||
return Architecture.arm64;
|
||||
case "x86_64":
|
||||
input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||
while ((line = input.readLine()) != null) {
|
||||
if (line.length() > 0) {
|
||||
if (line.contains("64")) {
|
||||
return Architecture.x86_64;
|
||||
default:
|
||||
throw new OsDetectionException("unsupported architecture: " + machine);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e instanceof OsDetectionException) {
|
||||
throw (OsDetectionException)e;
|
||||
}
|
||||
throw new OsDetectionException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return Architecture.x86;
|
||||
}
|
||||
|
||||
private static Architecture getMacOSXArchitecture() {
|
||||
BufferedReader input = null;
|
||||
try {
|
||||
Process proc = Runtime.getRuntime().exec("uname -m");
|
||||
try (BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
|
||||
String machine = input.readLine();
|
||||
switch (machine) {
|
||||
case "arm64":
|
||||
return Architecture.arm64;
|
||||
case "x86_64":
|
||||
String line;
|
||||
Process proc = Runtime.getRuntime().exec("sysctl hw");
|
||||
input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||
while ((line = input.readLine()) != null) {
|
||||
if (line.length() > 0) {
|
||||
if ((line.contains("cpu64bit_capable")) && (line.trim().endsWith("1"))) {
|
||||
return Architecture.x86_64;
|
||||
default:
|
||||
throw new OsDetectionException("unsupported architecture: " + machine);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e instanceof OsDetectionException) {
|
||||
throw (OsDetectionException)e;
|
||||
}
|
||||
throw new OsDetectionException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return Architecture.x86;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,12 +4,14 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
public class OsArchitecture {
|
||||
|
||||
public static final OsArchitecture WINDOWS_x86 = new OsArchitecture(OS.WINDOWS, Architecture.x86);
|
||||
public static final OsArchitecture WINDOWS_x86_64 = new OsArchitecture(OS.WINDOWS, Architecture.x86_64);
|
||||
|
||||
public static final OsArchitecture UNIX_x86 = new OsArchitecture(OS.UNIX, Architecture.x86);
|
||||
public static final OsArchitecture UNIX_x86_64 = new OsArchitecture(OS.UNIX, Architecture.x86_64);
|
||||
public static final OsArchitecture UNIX_arm64 = new OsArchitecture(OS.UNIX, Architecture.arm64);
|
||||
|
||||
public static final OsArchitecture MAC_OS_X_x86 = new OsArchitecture(OS.MAC_OS_X, Architecture.x86);
|
||||
public static final OsArchitecture MAC_OS_X_x86_64 = new OsArchitecture(OS.MAC_OS_X, Architecture.x86_64);
|
||||
public static final OsArchitecture MAC_OS_X_arm64 = new OsArchitecture(OS.MAC_OS_X, Architecture.arm64);
|
||||
|
||||
private final OS os;
|
||||
private final Architecture arch;
|
||||
@ -53,9 +55,4 @@ public class OsArchitecture {
|
||||
result = 31 * result + arch.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%s)", os.name(), arch.name());
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/redis-server-2.8.19
Normal file
BIN
src/main/resources/redis-server-2.8.19
Normal file
Binary file not shown.
BIN
src/main/resources/redis-server-2.8.19.app
Normal file
BIN
src/main/resources/redis-server-2.8.19.app
Normal file
Binary file not shown.
BIN
src/main/resources/redis-server-2.8.19.exe
Normal file
BIN
src/main/resources/redis-server-2.8.19.exe
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rf ./tests
|
||||
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
OUTPUT_DIR="$1"
|
||||
|
||||
if [ ! -f "$OUTPUT_DIR/redis.key" -o ! -f "$OUTPUT_DIR/redis.crt" -o ! -f "$OUTPUT_DIR/ca.crt" ]; then
|
||||
./gen-test-certs.sh
|
||||
fi
|
||||
@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# From https://github.com/redis/redis/blob/4930d19e70c391750479951022e207e19111eb55/redis/util/gen-test-certs.sh, under the license:
|
||||
#
|
||||
# Copyright (c) 2006-2020, Salvatore Sanfilippo
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Redis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
# Generate some test certificates which are used by the regression test suite:
|
||||
#
|
||||
# tests/tls/ca.{crt,key} Self signed CA certificate.
|
||||
# tests/tls/redis.{crt,key} A certificate with no key usage/policy restrictions.
|
||||
# tests/tls/client.{crt,key} A certificate restricted for SSL client usage.
|
||||
# tests/tls/server.{crt,key} A certificate restricted fro SSL server usage.
|
||||
# tests/tls/redis.dh DH Params file.
|
||||
|
||||
generate_cert() {
|
||||
local name=$1
|
||||
local cn="$2"
|
||||
local opts="$3"
|
||||
|
||||
local keyfile=tests/tls/${name}.key
|
||||
local certfile=tests/tls/${name}.crt
|
||||
|
||||
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048
|
||||
openssl req \
|
||||
-new -sha256 \
|
||||
-subj "/O=Redis Test/CN=$cn" \
|
||||
-key $keyfile | \
|
||||
openssl x509 \
|
||||
-req -sha256 \
|
||||
-CA tests/tls/ca.crt \
|
||||
-CAkey tests/tls/ca.key \
|
||||
-CAserial tests/tls/ca.txt \
|
||||
-CAcreateserial \
|
||||
-days 365 \
|
||||
$opts \
|
||||
-out $certfile
|
||||
}
|
||||
|
||||
mkdir -p tests/tls
|
||||
[ -f tests/tls/ca.key ] || openssl genrsa -out tests/tls/ca.key 4096
|
||||
openssl req \
|
||||
-x509 -new -nodes -sha256 \
|
||||
-key tests/tls/ca.key \
|
||||
-days 3650 \
|
||||
-subj '/O=Redis Test/CN=Certificate Authority' \
|
||||
-out tests/tls/ca.crt
|
||||
|
||||
cat > tests/tls/openssl.cnf <<_END_
|
||||
[ server_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = server
|
||||
|
||||
[ client_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = client
|
||||
_END_
|
||||
|
||||
generate_cert server "Server-only" "-extfile tests/tls/openssl.cnf -extensions server_cert"
|
||||
generate_cert client "Client-only" "-extfile tests/tls/openssl.cnf -extensions client_cert"
|
||||
generate_cert redis "Generic-cert"
|
||||
|
||||
[ -f tests/tls/redis.dh ] || openssl dhparam -out tests/tls/redis.dh 2048
|
||||
@ -1,15 +1,12 @@
|
||||
package redis.embedded;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.embedded.util.JedisUtil;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.net.Inet4Address;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -20,9 +17,6 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class RedisClusterTest {
|
||||
private final RedisSentinelBuilder sentinelBuilder = RedisSentinel.builder();
|
||||
private String bindAddress;
|
||||
|
||||
private Redis sentinel1;
|
||||
private Redis sentinel2;
|
||||
private Redis master1;
|
||||
@ -36,13 +30,6 @@ public class RedisClusterTest {
|
||||
sentinel2 = mock(Redis.class);
|
||||
master1 = mock(Redis.class);
|
||||
master2 = mock(Redis.class);
|
||||
|
||||
// Jedis translates ”localhost” to getLocalHost().getHostAddress() (see Jedis HostAndPort#getLocalHostQuietly),
|
||||
// which can vary from 127.0.0.1 (most notably, Debian/Ubuntu return 127.0.1.1)
|
||||
if (bindAddress == null) {
|
||||
bindAddress = Inet4Address.getLocalHost().getHostAddress();
|
||||
sentinelBuilder.bind(bindAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +97,7 @@ public class RedisClusterTest {
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRunWithSingleMasterNoSlavesCluster() throws Exception {
|
||||
//given
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelCount(1).replicationGroup("ourmaster", 0).build();
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelCount(1).replicationGroup("ourmaster", 0).build();
|
||||
cluster.start();
|
||||
|
||||
//when
|
||||
@ -120,7 +107,8 @@ public class RedisClusterTest {
|
||||
pool = new JedisSentinelPool("ourmaster", Sets.newHashSet("localhost:26379"));
|
||||
jedis = testPool(pool);
|
||||
} finally {
|
||||
closeQuietly(jedis, pool);
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -128,7 +116,7 @@ public class RedisClusterTest {
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRunWithSingleMasterAndOneSlave() throws Exception {
|
||||
//given
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelCount(1).replicationGroup("ourmaster", 1).build();
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelCount(1).replicationGroup("ourmaster", 1).build();
|
||||
cluster.start();
|
||||
|
||||
//when
|
||||
@ -138,7 +126,8 @@ public class RedisClusterTest {
|
||||
pool = new JedisSentinelPool("ourmaster", Sets.newHashSet("localhost:26379"));
|
||||
jedis = testPool(pool);
|
||||
} finally {
|
||||
closeQuietly(jedis, pool);
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -146,7 +135,7 @@ public class RedisClusterTest {
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRunWithSingleMasterMultipleSlaves() throws Exception {
|
||||
//given
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelCount(1).replicationGroup("ourmaster", 2).build();
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelCount(1).replicationGroup("ourmaster", 2).build();
|
||||
cluster.start();
|
||||
|
||||
//when
|
||||
@ -156,7 +145,8 @@ public class RedisClusterTest {
|
||||
pool = new JedisSentinelPool("ourmaster", Sets.newHashSet("localhost:26379"));
|
||||
jedis = testPool(pool);
|
||||
} finally {
|
||||
closeQuietly(jedis, pool);
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -164,7 +154,7 @@ public class RedisClusterTest {
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRunWithTwoSentinelsSingleMasterMultipleSlaves() throws Exception {
|
||||
//given
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelCount(2).replicationGroup("ourmaster", 2).build();
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelCount(2).replicationGroup("ourmaster", 2).build();
|
||||
cluster.start();
|
||||
|
||||
//when
|
||||
@ -174,7 +164,8 @@ public class RedisClusterTest {
|
||||
pool = new JedisSentinelPool("ourmaster", Sets.newHashSet("localhost:26379", "localhost:26380"));
|
||||
jedis = testPool(pool);
|
||||
} finally {
|
||||
closeQuietly(jedis, pool);
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -183,7 +174,7 @@ public class RedisClusterTest {
|
||||
public void testSimpleOperationsAfterRunWithTwoPredefinedSentinelsSingleMasterMultipleSlaves() throws Exception {
|
||||
//given
|
||||
List<Integer> sentinelPorts = Arrays.asList(26381, 26382);
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelPorts(sentinelPorts).replicationGroup("ourmaster", 2).build();
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelPorts(sentinelPorts).replicationGroup("ourmaster", 2).build();
|
||||
cluster.start();
|
||||
final Set<String> sentinelHosts = JedisUtil.portsToJedisHosts(sentinelPorts);
|
||||
|
||||
@ -194,7 +185,8 @@ public class RedisClusterTest {
|
||||
pool = new JedisSentinelPool("ourmaster", sentinelHosts);
|
||||
jedis = testPool(pool);
|
||||
} finally {
|
||||
closeQuietly(jedis, pool);
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -205,7 +197,7 @@ public class RedisClusterTest {
|
||||
final String master1 = "master1";
|
||||
final String master2 = "master2";
|
||||
final String master3 = "master3";
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).sentinelCount(3).quorumSize(2)
|
||||
final RedisCluster cluster = RedisCluster.builder().sentinelCount(3).quorumSize(2)
|
||||
.replicationGroup(master1, 1)
|
||||
.replicationGroup(master2, 1)
|
||||
.replicationGroup(master3, 1)
|
||||
@ -227,7 +219,12 @@ public class RedisClusterTest {
|
||||
jedis2 = testPool(pool2);
|
||||
jedis3 = testPool(pool3);
|
||||
} finally {
|
||||
closeQuietly(jedis1, pool1, jedis2, pool2, jedis3, pool3);
|
||||
if (jedis1 != null)
|
||||
pool1.returnResource(jedis1);
|
||||
if (jedis2 != null)
|
||||
pool2.returnResource(jedis2);
|
||||
if (jedis3 != null)
|
||||
pool3.returnResource(jedis3);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -238,7 +235,7 @@ public class RedisClusterTest {
|
||||
final String master1 = "master1";
|
||||
final String master2 = "master2";
|
||||
final String master3 = "master3";
|
||||
final RedisCluster cluster = RedisCluster.builder().withSentinelBuilder(sentinelBuilder).ephemeral().sentinelCount(3).quorumSize(2)
|
||||
final RedisCluster cluster = RedisCluster.builder().ephemeral().sentinelCount(3).quorumSize(2)
|
||||
.replicationGroup(master1, 1)
|
||||
.replicationGroup(master2, 1)
|
||||
.replicationGroup(master3, 1)
|
||||
@ -261,7 +258,12 @@ public class RedisClusterTest {
|
||||
jedis2 = testPool(pool2);
|
||||
jedis3 = testPool(pool3);
|
||||
} finally {
|
||||
closeQuietly(jedis1, pool1, jedis2, pool2, jedis3, pool3);
|
||||
if (jedis1 != null)
|
||||
pool1.returnResource(jedis1);
|
||||
if (jedis2 != null)
|
||||
pool2.returnResource(jedis2);
|
||||
if (jedis3 != null)
|
||||
pool3.returnResource(jedis3);
|
||||
cluster.stop();
|
||||
}
|
||||
}
|
||||
@ -277,11 +279,4 @@ public class RedisClusterTest {
|
||||
assertEquals(null, jedis.mget("xyz").get(0));
|
||||
return jedis;
|
||||
}
|
||||
|
||||
private void closeQuietly(Closeable... closeables) {
|
||||
for (Closeable closeable : closeables) {
|
||||
IOUtils.closeQuietly(closeable, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,38 +1,22 @@
|
||||
package redis.embedded;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class RedisSentinelTest {
|
||||
private String bindAddress;
|
||||
|
||||
private RedisSentinel sentinel;
|
||||
private RedisServer server;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
// Jedis translates ”localhost” to getLocalHost().getHostAddress() (see Jedis HostAndPort#getLocalHostQuietly),
|
||||
// which can vary from 127.0.0.1 (most notably, Debian/Ubuntu return 127.0.1.1)
|
||||
if (bindAddress == null) {
|
||||
bindAddress = Inet4Address.getLocalHost().getHostAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 3000L)
|
||||
public void testSimpleRun() throws Exception {
|
||||
server = new RedisServer();
|
||||
sentinel = RedisSentinel.builder().bind(bindAddress).build();
|
||||
sentinel = RedisSentinel.builder().build();
|
||||
sentinel.start();
|
||||
server.start();
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
@ -42,7 +26,7 @@ public class RedisSentinelTest {
|
||||
|
||||
@Test
|
||||
public void shouldAllowSubsequentRuns() throws Exception {
|
||||
sentinel = RedisSentinel.builder().bind(bindAddress).build();
|
||||
sentinel = RedisSentinel.builder().build();
|
||||
sentinel.start();
|
||||
sentinel.stop();
|
||||
|
||||
@ -57,7 +41,7 @@ public class RedisSentinelTest {
|
||||
public void testSimpleOperationsAfterRun() throws Exception {
|
||||
//given
|
||||
server = new RedisServer();
|
||||
sentinel = RedisSentinel.builder().bind(bindAddress).build();
|
||||
sentinel = RedisSentinel.builder().build();
|
||||
server.start();
|
||||
sentinel.start();
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
@ -73,7 +57,7 @@ public class RedisSentinelTest {
|
||||
//then
|
||||
assertEquals("1", jedis.mget("abc").get(0));
|
||||
assertEquals("2", jedis.mget("def").get(0));
|
||||
assertNull(jedis.mget("xyz").get(0));
|
||||
assertEquals(null, jedis.mget("xyz").get(0));
|
||||
} finally {
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
@ -82,34 +66,4 @@ public class RedisSentinelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwaitRedisSentinelReady() throws Exception {
|
||||
String readyPattern = RedisSentinel.builder().build().redisReadyPattern();
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-2.x-sentinel-startup-output.txt"))),
|
||||
readyPattern);
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-3.x-sentinel-startup-output.txt"))),
|
||||
readyPattern);
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-4.x-sentinel-startup-output.txt"))),
|
||||
readyPattern);
|
||||
}
|
||||
|
||||
private void assertReadyPattern(BufferedReader reader, String readyPattern) throws IOException {
|
||||
String outputLine;
|
||||
do {
|
||||
outputLine = reader.readLine();
|
||||
assertNotNull(outputLine);
|
||||
} while (!outputLine.matches(readyPattern));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,16 +8,12 @@ import redis.embedded.exceptions.RedisBuildingException;
|
||||
import redis.embedded.util.Architecture;
|
||||
import redis.embedded.util.OS;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RedisServerTest {
|
||||
|
||||
private RedisServer redisServer;
|
||||
|
||||
|
||||
@Test(timeout = 1500L)
|
||||
public void testSimpleRun() throws Exception {
|
||||
redisServer = new RedisServer(6379);
|
||||
@ -25,7 +21,7 @@ public class RedisServerTest {
|
||||
Thread.sleep(1000L);
|
||||
redisServer.stop();
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void shouldNotAllowMultipleRunsWithoutStop() throws Exception {
|
||||
try {
|
||||
@ -36,35 +32,35 @@ public class RedisServerTest {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldAllowSubsequentRuns() throws Exception {
|
||||
redisServer = new RedisServer(6379);
|
||||
redisServer.start();
|
||||
redisServer.stop();
|
||||
|
||||
|
||||
redisServer.start();
|
||||
redisServer.stop();
|
||||
|
||||
|
||||
redisServer.start();
|
||||
redisServer.stop();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRun() throws Exception {
|
||||
redisServer = new RedisServer(6379);
|
||||
redisServer.start();
|
||||
|
||||
|
||||
JedisPool pool = null;
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
pool = new JedisPool("localhost", 6379);
|
||||
jedis = pool.getResource();
|
||||
jedis.mset("abc", "1", "def", "2");
|
||||
|
||||
|
||||
assertEquals("1", jedis.mget("abc").get(0));
|
||||
assertEquals("2", jedis.mget("def").get(0));
|
||||
assertNull(jedis.mget("xyz").get(0));
|
||||
assertEquals(null, jedis.mget("xyz").get(0));
|
||||
} finally {
|
||||
if (jedis != null)
|
||||
pool.returnResource(jedis);
|
||||
@ -97,12 +93,11 @@ public class RedisServerTest {
|
||||
@Test
|
||||
public void shouldOverrideDefaultExecutable() throws Exception {
|
||||
RedisExecProvider customProvider = RedisExecProvider.defaultProvider()
|
||||
.override(OS.UNIX, Architecture.x86, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-386").getFile())
|
||||
.override(OS.UNIX, Architecture.x86_64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-amd64").getFile())
|
||||
.override(OS.UNIX, Architecture.arm64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-arm64").getFile())
|
||||
.override(OS.MAC_OS_X, Architecture.x86_64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-darwin-amd64").getFile())
|
||||
.override(OS.MAC_OS_X, Architecture.arm64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-darwin-arm64").getFile());
|
||||
|
||||
.override(OS.UNIX, Resources.getResource("redis-server-2.8.19").getFile())
|
||||
.override(OS.WINDOWS, Architecture.x86, Resources.getResource("redis-server-2.8.19.exe").getFile())
|
||||
.override(OS.WINDOWS, Architecture.x86_64, Resources.getResource("redis-server-2.8.19.exe").getFile())
|
||||
.override(OS.MAC_OS_X, Resources.getResource("redis-server-2.8.19").getFile());
|
||||
|
||||
redisServer = new RedisServerBuilder()
|
||||
.redisExecProvider(customProvider)
|
||||
.build();
|
||||
@ -112,47 +107,12 @@ public class RedisServerTest {
|
||||
public void shouldFailWhenBadExecutableGiven() throws Exception {
|
||||
RedisExecProvider buggyProvider = RedisExecProvider.defaultProvider()
|
||||
.override(OS.UNIX, "some")
|
||||
.override(OS.WINDOWS, Architecture.x86, "some")
|
||||
.override(OS.WINDOWS, Architecture.x86_64, "some")
|
||||
.override(OS.MAC_OS_X, "some");
|
||||
|
||||
|
||||
redisServer = new RedisServerBuilder()
|
||||
.redisExecProvider(buggyProvider)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwaitRedisServerReady() throws Exception {
|
||||
String readyPattern = RedisServer.builder().build().redisReadyPattern();
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-2.x-standalone-startup-output.txt"))),
|
||||
readyPattern);
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-3.x-standalone-startup-output.txt"))),
|
||||
readyPattern);
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-4.x-standalone-startup-output.txt"))),
|
||||
readyPattern);
|
||||
|
||||
assertReadyPattern(new BufferedReader(
|
||||
new InputStreamReader(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("redis-6.x-standalone-startup-output.txt"))),
|
||||
readyPattern);
|
||||
}
|
||||
|
||||
private void assertReadyPattern(BufferedReader reader, String readyPattern) throws IOException {
|
||||
String outputLine;
|
||||
do {
|
||||
outputLine = reader.readLine();
|
||||
assertNotNull(outputLine);
|
||||
} while (!outputLine.matches(readyPattern));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
package redis.embedded;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.embedded.util.JarUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class RedisTlsTest {
|
||||
|
||||
private RedisServer redisServer;
|
||||
|
||||
private static File certFile;
|
||||
private static File keyFile;
|
||||
private static File caCertFile;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() throws Exception {
|
||||
certFile = getFile("redis.crt");
|
||||
keyFile = getFile("redis.key");
|
||||
caCertFile = getFile("ca.crt");
|
||||
|
||||
File trustStore = File.createTempFile("embedded-redis-test-truststore", ".jks");
|
||||
trustStore.deleteOnExit();
|
||||
|
||||
Certificate cert;
|
||||
try (FileInputStream certInput = new FileInputStream(certFile)) {
|
||||
cert = CertificateFactory.getInstance("X.509").generateCertificate(certInput);
|
||||
}
|
||||
|
||||
KeyStore keyStore = KeyStore.getInstance("jks");
|
||||
keyStore.load(null, null);
|
||||
|
||||
keyStore.setCertificateEntry("testCaCert", cert);
|
||||
try (FileOutputStream out = new FileOutputStream(trustStore)) {
|
||||
keyStore.store(out, new char[0]);
|
||||
}
|
||||
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore.getAbsolutePath());
|
||||
System.setProperty("javax.net.ssl.trustStoreType", "jks");
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
redisServer = RedisServer.builder()
|
||||
.port(0) // disable non-tls
|
||||
.tlsPort(6380)
|
||||
.setting("tls-cert-file " + certFile.getAbsolutePath())
|
||||
.setting("tls-key-file " + keyFile.getAbsolutePath())
|
||||
.setting("tls-ca-cert-file " + caCertFile.getAbsolutePath())
|
||||
.setting("tls-auth-clients no") // disable mTLS, for simplicity
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Test(timeout = 1500L)
|
||||
public void testSimpleRun() throws Exception {
|
||||
redisServer.start();
|
||||
Thread.sleep(1000L);
|
||||
redisServer.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOperationsAfterRun() {
|
||||
redisServer.start();
|
||||
|
||||
try (JedisPool pool = new JedisPool("localhost", redisServer.tlsPorts().get(0), true);
|
||||
Jedis jedis = pool.getResource()) {
|
||||
jedis.mset("abc", "1", "def", "2");
|
||||
|
||||
assertEquals("1", jedis.mget("abc").get(0));
|
||||
assertEquals("2", jedis.mget("def").get(0));
|
||||
assertNull(jedis.mget("xyz").get(0));
|
||||
} finally {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private static File getFile(String path) throws IOException {
|
||||
return fileExists(path) ?
|
||||
new File(path) :
|
||||
JarUtil.extractFileFromJar(path);
|
||||
}
|
||||
|
||||
private static boolean fileExists(String path) {
|
||||
return new File(path).exists();
|
||||
}
|
||||
}
|
||||
49
src/test/java/redis/embedded/SpringDataConnectivityTest.java
Normal file
49
src/test/java/redis/embedded/SpringDataConnectivityTest.java
Normal file
@ -0,0 +1,49 @@
|
||||
package redis.embedded;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SpringDataConnectivityTest {
|
||||
|
||||
private RedisServer redisServer;
|
||||
private RedisTemplate<String, String> template;
|
||||
private JedisConnectionFactory connectionFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
redisServer = new RedisServer(6379);
|
||||
redisServer.start();
|
||||
|
||||
JedisShardInfo shardInfo = new JedisShardInfo("localhost", 6379);
|
||||
connectionFactory = new JedisConnectionFactory();
|
||||
connectionFactory.setShardInfo(shardInfo);
|
||||
|
||||
template = new StringRedisTemplate();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
template.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToUseSpringData() throws Exception {
|
||||
// given
|
||||
template.opsForValue().set("foo", "bar");
|
||||
|
||||
// when
|
||||
String result = template.opsForValue().get("foo");
|
||||
|
||||
// then
|
||||
assertEquals("bar", result);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 2.8.19 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in sentinel mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 26379
|
||||
| `-._ `._ / _.-' | PID: 5532
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
[5532] 18 May 18:23:19.755 # Sentinel runid is 19036a5984e785f22fbf267af283649226736049
|
||||
@ -1,20 +0,0 @@
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 2.8.19 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in stand alone mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 6212
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
[6212] 18 May 18:23:17.244 # Server started, Redis version 2.8.19
|
||||
[6212] 18 May 18:23:17.244 * The server is now ready to accept connections on port 6379
|
||||
@ -1,19 +0,0 @@
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 3.2.100 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in sentinel mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 8332
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
[8332] 18 May 12:24:04.651 # Sentinel ID is 4bb1b2d80c74deb14e116664261c47b5a9c4b185
|
||||
@ -1,20 +0,0 @@
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 3.2.100 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in standalone mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 1592
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
[1592] 18 May 12:22:56.535 # Server started, Redis version 3.2.100
|
||||
[1592] 18 May 12:22:56.535 * The server is now ready to accept connections on port 6379
|
||||
@ -1,26 +0,0 @@
|
||||
2091:X 18 May 18:04:58.961 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||
2091:X 18 May 18:04:58.962 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=2091, just started
|
||||
2091:X 18 May 18:04:58.962 # Configuration loaded
|
||||
2091:X 18 May 18:04:58.963 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
|
||||
2091:X 18 May 18:04:58.963 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
|
||||
2091:X 18 May 18:04:58.963 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in sentinel mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 2091
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
2091:X 18 May 18:04:58.964 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
|
||||
2091:X 18 May 18:04:58.970 # Sentinel ID is 70592a23712d81e2ebc460624a95a0a0fd13a737
|
||||
@ -1,29 +0,0 @@
|
||||
1780:C 18 May 18:03:03.442 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||
1780:C 18 May 18:03:03.442 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=1780, just started
|
||||
1780:C 18 May 18:03:03.442 # Configuration loaded
|
||||
1780:M 18 May 18:03:03.443 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
|
||||
1780:M 18 May 18:03:03.443 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
|
||||
1780:M 18 May 18:03:03.443 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in standalone mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 1780
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
1780:M 18 May 18:03:03.444 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
|
||||
1780:M 18 May 18:03:03.445 # Server initialized
|
||||
1780:M 18 May 18:03:03.445 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
|
||||
1780:M 18 May 18:03:03.445 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
|
||||
1780:M 18 May 18:03:03.445 * Ready to accept connections
|
||||
@ -1,26 +0,0 @@
|
||||
124304:C 26 Jun 2020 12:23:30.115 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||
124304:C 26 Jun 2020 12:23:30.115 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=124304, just started
|
||||
124304:C 26 Jun 2020 12:23:30.115 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/main/resources/redis-server-6.0.5 /path/to/redis.conf
|
||||
124304:M 26 Jun 2020 12:23:30.116 * Increased maximum number of open files to 10032 (it was originally set to 1024).
|
||||
_._
|
||||
_.-``__ ''-._
|
||||
_.-`` `. `_. ''-._ Redis 6.0.5 (00000000/0) 64 bit
|
||||
.-`` .-```. ```\/ _.,_ ''-._
|
||||
( ' , .-` | `, ) Running in standalone mode
|
||||
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
|
||||
| `-._ `._ / _.-' | PID: 124304
|
||||
`-._ `-._ `-./ _.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' | http://redis.io
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
|`-._`-._ `-.__.-' _.-'_.-'|
|
||||
| `-._`-._ _.-'_.-' |
|
||||
`-._ `-._`-.__.-'_.-' _.-'
|
||||
`-._ `-.__.-' _.-'
|
||||
`-._ _.-'
|
||||
`-.__.-'
|
||||
|
||||
124304:M 26 Jun 2020 12:23:30.116 # Server initialized
|
||||
124304:M 26 Jun 2020 12:23:30.116 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
|
||||
124304:M 26 Jun 2020 12:23:30.116 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
|
||||
124304:M 26 Jun 2020 12:23:30.116 * Ready to accept connections
|
||||
Loading…
Reference in New Issue
Block a user