Skip to content

Commit

Permalink
Merge pull request #6 from rundeck-plugins/test-official-docker
Browse files Browse the repository at this point in the history
Official Docker Integration Test
  • Loading branch information
ltamaster authored Aug 23, 2018
2 parents c721ddc + 06a5574 commit aa4ae1a
Show file tree
Hide file tree
Showing 29 changed files with 172 additions and 613 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ before_install:
- sudo apt-get update -qq
- sudo chsh --shell $(which bash)
script:
- './gradlew clean build && DOCKER_COMPOSE_SPEC=docker-compose-vault.yaml bash run-docker-vault-tests.sh'
- './gradlew clean build && bash run-docker-vault-tests.sh'
addons:
hostname: rdbuild
apt:
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'pl.allegro.tech.build.axion-release' version '1.7.1'
}
ext.rundeckVersion='2.10.0'
ext.rundeckVersion='3.0.2-20180803'
defaultTasks 'clean','build'
apply plugin: 'java'
apply plugin: 'idea'
Expand All @@ -16,6 +16,7 @@ ext.rundeckPluginVersion= '1.2'
ext.pluginClassNames='io.github.valfadeev.rundeck.plugin.vault.VaultStoragePlugin'

scmVersion {
ignoreUncommittedChanges = false
tag {
prefix = ''
versionSeparator = ''
Expand Down
12 changes: 4 additions & 8 deletions run-docker-vault-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ rd_get_version(){

rd_get_plugin_version(){
local CUR_VERSION=$(grep plugin.version.number= `pwd`/version.properties | cut -d= -f 2)

echo "${CUR_VERSION}"
}

Expand All @@ -35,7 +34,7 @@ copy_jar(){
local FARGS=("$@")
local DIR=${FARGS[0]}
local -a VERS=( $( rd_get_plugin_version ) )
local JAR=vault-storage-${VERS[0]}.jar
local JAR=$(basename "$PWD")-*.jar
local buildJar=$PWD/build/libs/$JAR
test -f $buildJar || die "Jar file not found $buildJar"
mkdir -p $DIR
Expand All @@ -45,26 +44,23 @@ copy_jar(){
run_tests(){
local FARGS=("$@")
local DIR=${FARGS[0]}
local RUNDECK_VERSION=${FARGS[1]}

cd $DIR

export RUNDECK_VERSION=$RUNDECK_VERSION
bash $DIR/test-vault.sh
bash $DIR/test-existing-vault.sh
}
run_docker_test(){
local FARGS=("$@")
local DIR=${FARGS[0]}
local RUNDECK_VERSION=${FARGS[1]}
local launcherJar=$( copy_jar $DIR ) || die "Failed to copy jar"
run_tests $DIR $RUNDECK_VERSION
echo "Testing: $launcherJar"
run_tests $DIR
}


main() {
check_args
export RUNDECK_VERSION=( $( rd_get_version ) )
run_docker_test $DOCKER_DIR $RUNDECK_VERSION
run_docker_test $DOCKER_DIR
}
main
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class KeyObject {

abstract Map<String, Object> saveResource(ResourceMeta content, String event, ByteArrayOutputStream baoStream);
abstract ResourceBase loadResource();
abstract boolean delete(Logical vault,String vaultPrefix);
abstract boolean delete(Logical vault,String vaultSecretBackend ,String vaultPrefix);

//empty object or null object
public KeyObject(Path path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ else if (type.equals(VaultStoragePlugin.PASSWORD_MIME_TYPE)) {
}

@Override
boolean delete(final Logical vault,String vaultPrefix) {
boolean delete(final Logical vault,String vaultSecretBackend, String vaultPrefix) {

try {
vault.delete(VaultStoragePlugin.getVaultPath(path.getPath(),vaultPrefix));
vault.delete(VaultStoragePlugin.getVaultPath(path.getPath(), vaultSecretBackend, vaultPrefix));
return true;
} catch (VaultException e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ ResourceBase loadResource(){
}

@Override
boolean delete(final Logical vault,String vaultPrefix) {
boolean delete(final Logical vault,String vaultSecretBackend, String vaultPrefix) {
String event="delete";

if(this.parent!=null){
Expand All @@ -171,7 +171,7 @@ boolean delete(final Logical vault,String vaultPrefix) {
this.parent.getKeys().remove(key);

try {
vault.write(VaultStoragePlugin.getVaultPath(this.parent.getPath().getPath(),vaultPrefix), this.parent.getKeys());
vault.write(VaultStoragePlugin.getVaultPath(this.parent.getPath().getPath(),vaultSecretBackend, vaultPrefix), this.parent.getKeys());
return true;
} catch (VaultException e) {
throw new StorageException(
Expand All @@ -183,7 +183,7 @@ boolean delete(final Logical vault,String vaultPrefix) {

}else{
try {
vault.delete(VaultStoragePlugin.getVaultPath(path.getPath(),vaultPrefix));
vault.delete(VaultStoragePlugin.getVaultPath(path.getPath(),vaultSecretBackend, vaultPrefix));
return true;
} catch (VaultException e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void configure(Properties configuration) throws ConfigurationException {
}
}

public static String getVaultPath(String rawPath, String vaultPrefix) {
public static String getVaultPath(String rawPath, String vaultSecretBackend, String vaultPrefix) {
return String.format("%s/%s/%s", vaultSecretBackend, vaultPrefix, rawPath);
}

Expand All @@ -86,7 +86,7 @@ private boolean isDir(String key) {
private boolean isVaultDir(String key) {

try{
if(vault.list(getVaultPath(key,vaultPrefix)).size() > 0){
if(vault.list(getVaultPath(key,vaultSecretBackend,vaultPrefix)).size() > 0){
return true;
}else{
if(!rundeckObject) {
Expand Down Expand Up @@ -140,7 +140,7 @@ private VaultResponse saveResource(Path path, ResourceMeta content, String event
Map<String, Object> payload=object.saveResource(content,event,baoStream);

try {
return vault.write(getVaultPath(object.getPath().getPath(),vaultPrefix), payload);
return vault.write(getVaultPath(object.getPath().getPath(),vaultSecretBackend,vaultPrefix), payload);
} catch (VaultException e) {
throw new StorageException(
String.format("Encountered error while writing data to Vault %s",
Expand Down Expand Up @@ -180,7 +180,7 @@ private Set<Resource<ResourceMeta>> listResources(Path path, KeyType type) {
List<String> response;

try {
response = vault.list(getVaultPath(path.getPath(),vaultPrefix));
response = vault.list(getVaultPath(path.getPath(),vaultSecretBackend,vaultPrefix));
} catch (VaultException e) {
throw StorageException.listException(
path,
Expand Down Expand Up @@ -252,7 +252,7 @@ private Set<Resource<ResourceMeta>> listResources(Path path, KeyType type) {
@Override
public boolean hasPath(Path path) {
try {
if(vault.list(getVaultPath(path.getPath(),vaultPrefix)).size() > 0){
if(vault.list(getVaultPath(path.getPath(),vaultSecretBackend,vaultPrefix)).size() > 0){
return true;
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public boolean hasResource(String path) {
@Override
public boolean hasDirectory(Path path) {
try {
List<String> list=vault.list(getVaultPath(path.getPath(),vaultPrefix));
List<String> list=vault.list(getVaultPath(path.getPath(),vaultSecretBackend,vaultPrefix));

if(list.size() > 0){
return list.size() > 0;
Expand Down Expand Up @@ -372,7 +372,7 @@ public Set<Resource<ResourceMeta>> listDirectorySubdirs(String path) {
@Override
public boolean deleteResource(Path path) {
KeyObject object = this.getVaultObject(path);
return object.delete(vault,vaultPrefix);
return object.delete(vault,vaultSecretBackend,vaultPrefix);
}

@Override
Expand Down
31 changes: 15 additions & 16 deletions test/docker/docker-compose-existing-vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: '2'

services:
vault:
#image: vault:0.9.6
build: dockers/vault
ports:
- "8200:8200"
Expand All @@ -13,26 +12,26 @@ services:
- VAULT_DEV_LISTEN_ADDRESS=vault:8200
- VAULT_ADDR=http://vault:8200
- VAULT_TOKEN=${VAULT_TOKEN}
#entrypoint: vault server -config=/vault/config -dev

rundeck1:
hostname: rundeck1
image: rdtest:latest
#build:
# context: dockers/rundeck
build:
context: dockers/rundeckvault/
links:
- vault
- vault
environment:
- RUNDECK_NODE=rundeck1
- RUNDECK_URL=http://rundeck1:4440
- LAUNCHER_URL=${LAUNCHER_URL}
- SETUP_TEST_PROJECT=vaulttest
- VAULT_URL=http://vault:8200
- VAULT_TOKEN=${VAULT_TOKEN}
- VAULT_BEHAVIOUR=vault
- CONFIG_SCRIPT_PRESTART=scripts/config_vault_plugin.sh
- RUNDECK_GRAILS_URL=http://rundeck1:4440
- RUNDECK_NODE=rundeck1
- SETUP_TEST_PROJECT=vaulttest
- RUNDECK_STORAGE_PROVIDER_1_TYPE=vault-storage
- RUNDECK_STORAGE_PROVIDER_1_PATH=keys
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_PREFIX=rundeck
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_ADDRESS=http://vault:8200
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_TOKEN=${VAULT_TOKEN}
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_BEHAVIOUR=vault
- VAULT_TOKEN=${VAULT_TOKEN}
ports:
- "2222:22"
- "4440:4440"
- "4440:4440"
volumes:
logs:
resources:
29 changes: 13 additions & 16 deletions test/docker/docker-compose-vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: '2'

services:
vault:
#image: vault:0.9.6
build: dockers/vault
ports:
- "8200:8200"
Expand All @@ -13,26 +12,24 @@ services:
- VAULT_DEV_LISTEN_ADDRESS=vault:8200
- VAULT_ADDR=http://vault:8200
- VAULT_TOKEN=${VAULT_TOKEN}
#entrypoint: vault server -config=/vault/config -dev && run.sh
rundeck1:
hostname: rundeck1
image: rdtest:latest
#build:
# context: dockers/rundeck
build:
context: dockers/rundeckvault/
links:
- vault
- vault
environment:
- RUNDECK_NODE=rundeck1
- RUNDECK_URL=http://rundeck1:4440
- LAUNCHER_URL=${LAUNCHER_URL}
- SETUP_TEST_PROJECT=vaulttest
- VAULT_URL=http://vault:8200
- VAULT_TOKEN=${VAULT_TOKEN}
- VAULT_BEHAVIOUR=rundeck
- CONFIG_SCRIPT_PRESTART=scripts/config_vault_plugin.sh
- RUNDECK_GRAILS_URL=http://rundeck1:4440
- RUNDECK_NODE=rundeck1
- SETUP_TEST_PROJECT=vaulttest
- RUNDECK_STORAGE_PROVIDER_1_TYPE=vault-storage
- RUNDECK_STORAGE_PROVIDER_1_PATH=keys
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_PREFIX=rundeck
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_ADDRESS=http://vault:8200
- RUNDECK_STORAGE_PROVIDER_1_CONFIG_TOKEN=${VAULT_TOKEN}
- VAULT_TOKEN=${VAULT_TOKEN}
ports:
- "2222:22"
- "4440:4440"
- "4440:4440"
volumes:
logs:
resources:
104 changes: 0 additions & 104 deletions test/docker/dockers/rundeck/Dockerfile

This file was deleted.

Loading

0 comments on commit aa4ae1a

Please sign in to comment.