forked from toolshed/abra
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
309fc72c38 |
@@ -7,3 +7,4 @@
|
|||||||
/bin
|
/bin
|
||||||
dist/
|
dist/
|
||||||
tests/integration/.bats
|
tests/integration/.bats
|
||||||
|
tests/resources/path_to_repo
|
||||||
|
|||||||
@@ -84,3 +84,53 @@ build-mo:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
@goreleaser release --clean
|
@goreleaser release --clean
|
||||||
|
|
||||||
|
CLIENT_VM := abra-client
|
||||||
|
vm-client-status:
|
||||||
|
sudo systemctl status microvm@$(CLIENT_VM).service
|
||||||
|
vm-client-create:test-integration-hosts
|
||||||
|
sudo microvm -f git+file://$$(pwd) -c $(CLIENT_VM)
|
||||||
|
vm-client-start:
|
||||||
|
sudo systemctl start microvm@$(CLIENT_VM).service
|
||||||
|
vm-client-update:test-integration-hosts
|
||||||
|
sudo microvm -R -f git+file://$$(pwd) -u $(CLIENT_VM)
|
||||||
|
vm-client-run:
|
||||||
|
sudo microvm -f git+file://$$(pwd) -r $(CLIENT_VM)
|
||||||
|
vm-client-stop:
|
||||||
|
sudo systemctl stop microvm@$(CLIENT_VM)
|
||||||
|
vm-client-delete: vm-client-stop
|
||||||
|
sudo rm -rf /var/lib/microvms/$(CLIENT_VM)
|
||||||
|
vm-client-connect:
|
||||||
|
ssh abra@10.0.0.2 -i ./tests/resources/local_integration_ssh
|
||||||
|
|
||||||
|
SERVER_VM := abra-server
|
||||||
|
vm-server-status:
|
||||||
|
sudo systemctl status microvm@$(SERVER_VM).service
|
||||||
|
vm-server-create:
|
||||||
|
sudo microvm -f git+file://$$(pwd) -c $(SERVER_VM)
|
||||||
|
vm-server-start:
|
||||||
|
sudo systemctl start microvm@$(SERVER_VM).service
|
||||||
|
vm-server-update:
|
||||||
|
sudo microvm -R -f git+file://$$(pwd) -u $(SERVER_VM)
|
||||||
|
vm-server-run:
|
||||||
|
sudo microvm -f git+file://$$(pwd) -r $(SERVER_VM)
|
||||||
|
vm-server-stop:
|
||||||
|
sudo systemctl stop microvm@$(SERVER_VM)
|
||||||
|
vm-server-delete: vm-server-stop
|
||||||
|
sudo rm -rf /var/lib/microvms/$(SERVER_VM)
|
||||||
|
vm-server-connect:
|
||||||
|
ssh abra@10.0.0.3 -i ./tests/resources/local_integration_ssh
|
||||||
|
|
||||||
|
test-integration-hosts:
|
||||||
|
./scripts/tests/extra_hosts
|
||||||
|
|
||||||
|
# TEST_INTEGRATION_FILES overrides the default of running all test files
|
||||||
|
ifdef TEST_INTEGRATION_FILES
|
||||||
|
test_files := $(TEST_INTEGRATION_FILES);
|
||||||
|
else
|
||||||
|
test_files := *;
|
||||||
|
endif
|
||||||
|
test-integration: build
|
||||||
|
chmod 600 ./tests/resources/local_integration_ssh
|
||||||
|
ssh-add ./tests/resources/local_integration_ssh
|
||||||
|
@bats -Tp --verbose-run tests/integration/$(test_files)
|
||||||
|
|||||||
Generated
+38
@@ -18,6 +18,27 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"microvm": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"spectrum": "spectrum"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1784666190,
|
||||||
|
"narHash": "sha256-xgfS6slV7J3baMooNN1UuBi51RIgg9y0DbCxfSA0668=",
|
||||||
|
"owner": "astro",
|
||||||
|
"repo": "microvm.nix",
|
||||||
|
"rev": "fa5340ac684cdce8a22b6d4a0bcebb0cc999275e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "astro",
|
||||||
|
"repo": "microvm.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778443072,
|
"lastModified": 1778443072,
|
||||||
@@ -37,9 +58,26 @@
|
|||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
|
"microvm": "microvm",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"spectrum": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1783694892,
|
||||||
|
"narHash": "sha256-xO8f7Qng+18FK2UlB9vcrkxCaQMCt5WjCH24aW/11eg=",
|
||||||
|
"ref": "refs/heads/main",
|
||||||
|
"rev": "24c4346e30fdea8d8e80f34aec3554a15a667d24",
|
||||||
|
"revCount": 1410,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://spectrum-os.org/git/spectrum"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://spectrum-os.org/git/spectrum"
|
||||||
|
}
|
||||||
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|||||||
@@ -4,34 +4,103 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
microvm = {
|
||||||
|
url = "github:astro/microvm.nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
|
microvm,
|
||||||
flake-utils,
|
flake-utils,
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
let
|
||||||
system:
|
system = "x86_64-linux";
|
||||||
let
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
publicKey = builtins.readFile ./tests/resources/local_integration_ssh.pub;
|
||||||
in
|
privateKey = builtins.readFile ./tests/resources/local_integration_ssh;
|
||||||
{
|
pathToRepo = builtins.readFile ./tests/resources/path_to_repo;
|
||||||
packages = rec {
|
# local DNS aliases for the server host
|
||||||
abra = pkgs.callPackage ./package.nix { };
|
extraHosts = builtins.readFile ./tests/resources/extra_hosts;
|
||||||
default = abra;
|
username = "abra";
|
||||||
|
password = "abra";
|
||||||
|
defaultDNS = [
|
||||||
|
# Quad9.net
|
||||||
|
"9.9.9.9"
|
||||||
|
"149.112.112.112"
|
||||||
|
"2620:fe::fe"
|
||||||
|
"2620:fe::9"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
nixosConfigurations = {
|
||||||
|
abra-client = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
microvm.nixosModules.microvm
|
||||||
|
./nix/hosts/client/configuration.nix
|
||||||
|
];
|
||||||
|
specialArgs = {
|
||||||
|
inherit
|
||||||
|
publicKey
|
||||||
|
privateKey
|
||||||
|
username
|
||||||
|
password
|
||||||
|
defaultDNS
|
||||||
|
extraHosts
|
||||||
|
pathToRepo
|
||||||
|
;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
apps = rec {
|
abra-server = nixpkgs.lib.nixosSystem {
|
||||||
abra = flake-utils.lib.mkApp { drv = self.packages.${system}.abra; };
|
system = "x86_64-linux";
|
||||||
default = abra;
|
modules = [
|
||||||
|
microvm.nixosModules.microvm
|
||||||
|
./nix/hosts/server/configuration.nix
|
||||||
|
];
|
||||||
|
specialArgs = {
|
||||||
|
inherit
|
||||||
|
publicKey
|
||||||
|
privateKey
|
||||||
|
username
|
||||||
|
password
|
||||||
|
defaultDNS
|
||||||
|
;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
devShells.default = pkgs.mkShell {
|
};
|
||||||
packages = with pkgs; [
|
nixosModules = rec {
|
||||||
go_1_26
|
host = {
|
||||||
gnumake
|
imports = [
|
||||||
|
microvm.nixosModules.host
|
||||||
|
./nix/modules/host.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
default = host;
|
||||||
);
|
};
|
||||||
|
packages = rec {
|
||||||
|
abra = pkgs.callPackage ./nix/package.nix { };
|
||||||
|
default = abra;
|
||||||
|
};
|
||||||
|
apps = rec {
|
||||||
|
abra = flake-utils.lib.mkApp { drv = self.packages.${system}.abra; };
|
||||||
|
default = abra;
|
||||||
|
};
|
||||||
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
|
# testing env variables
|
||||||
|
BATS_LIB_PATH = "~/.local/share/bats/";
|
||||||
|
TEST_SERVER = "abra.local";
|
||||||
|
ABRA_DIR = "$HOME/.abra_test";
|
||||||
|
|
||||||
|
packages = with pkgs; [
|
||||||
|
go_1_26
|
||||||
|
gnumake
|
||||||
|
gopls
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
buildGo126Module,
|
|
||||||
fetchgit,
|
|
||||||
lib,
|
|
||||||
installShellFiles,
|
|
||||||
}:
|
|
||||||
|
|
||||||
buildGo126Module rec {
|
|
||||||
pname = "abra";
|
|
||||||
version = "0.13.0-beta";
|
|
||||||
rev = "06a57ded025a43c80f94d4e65299add8a31830dc";
|
|
||||||
|
|
||||||
src = fetchgit {
|
|
||||||
url = "https://git.coopcloud.tech/toolshed/abra.git";
|
|
||||||
tag = version;
|
|
||||||
hash = "sha256-rgoK0TY0WLSQ39lPvVM80zW/qJF40VFBSxYDOaKXZQo=";
|
|
||||||
};
|
|
||||||
|
|
||||||
vendorHash = null;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
installShellFiles
|
|
||||||
];
|
|
||||||
|
|
||||||
env.CGO_ENABLED = 0;
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
go build -ldflags="-s -w -X 'main.Commit=${rev}' -X 'main.Version=${version}'" ./cmd/abra
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
install -D abra $out/bin/abra
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
export ABRA_DIR="$out"
|
|
||||||
$out/bin/abra autocomplete bash >abra.bash
|
|
||||||
$out/bin/abra autocomplete fish >abra.fish
|
|
||||||
$out/bin/abra autocomplete zsh >abra.zsh
|
|
||||||
installShellCompletion abra.{bash,fish,zsh}
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "The Co-op Cloud utility belt";
|
|
||||||
homepage = "https://docs.coopcloud.tech/abra";
|
|
||||||
changelog = "https://git.coopcloud.tech/toolshed/abra/releases/tag/${version}";
|
|
||||||
mainProgram = "abra";
|
|
||||||
license = licenses.gpl3Plus;
|
|
||||||
maintainers = "devydave";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
+2
-1
@@ -7,4 +7,5 @@
|
|||||||
|
|
||||||
* Integration tests are in `./tests/integration`. Please see [these
|
* Integration tests are in `./tests/integration`. Please see [these
|
||||||
docs](https://docs.coopcloud.tech/abra/hack/#integration-tests) for
|
docs](https://docs.coopcloud.tech/abra/hack/#integration-tests) for
|
||||||
instructions and tips on how to run them.
|
instructions and tips on how to run them. If you want to run it locally via nix,
|
||||||
|
read the [nix testing docs](../nix/hosts/README.md).
|
||||||
|
|||||||
@@ -598,8 +598,7 @@ teardown(){
|
|||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' \
|
_inspect_env_test_app
|
||||||
$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "WITH_COMMENT=foo"
|
assert_output --partial "WITH_COMMENT=foo"
|
||||||
|
|
||||||
@@ -610,8 +609,7 @@ teardown(){
|
|||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --force
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --force
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' \
|
_inspect_env_test_app
|
||||||
$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)
|
|
||||||
assert_success
|
assert_success
|
||||||
refute_output --partial "WITH_COMMENT=foo"
|
refute_output --partial "WITH_COMMENT=foo"
|
||||||
assert_output --partial "WITH_COMMENT=bar"
|
assert_output --partial "WITH_COMMENT=bar"
|
||||||
@@ -629,8 +627,14 @@ teardown(){
|
|||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker service inspect --format '{{ range .Endpoint.Ports }}{{ .Protocol }}={{ .PublishedPort }}{{ end }}' \
|
if _is_local;
|
||||||
|
then
|
||||||
|
run docker service inspect --format "{{ range .Endpoint.Ports }}{{ .Protocol }}={{ .PublishedPort }}{{ end }}" \
|
||||||
"${TEST_APP_DOMAIN//./_}_app"
|
"${TEST_APP_DOMAIN//./_}_app"
|
||||||
|
else
|
||||||
|
run ssh "$TEST_SERVER" "docker service inspect --format '{{ range .Endpoint.Ports }}{{ .Protocol }}={{ .PublishedPort }}{{ end }}' ${TEST_APP_DOMAIN//./_}_app"
|
||||||
|
fi
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "tcp=1312"
|
assert_output --partial "tcp=1312"
|
||||||
assert_output --partial "udp=1312"
|
assert_output --partial "udp=1312"
|
||||||
@@ -724,7 +728,8 @@ teardown(){
|
|||||||
run sed -i 's/version=0.3.5+1.21.0/version=0.4.0+1.21.5/' "$recipeDir/compose.yml"
|
run sed -i 's/version=0.3.5+1.21.0/version=0.4.0+1.21.5/' "$recipeDir/compose.yml"
|
||||||
assert_success
|
assert_success
|
||||||
_git_commit
|
_git_commit
|
||||||
run git -C "$recipeDir" tag "0.4.0+1.21.5"
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \
|
||||||
|
-a "0.4.0+1.21.5" -m "fake: 0.4.0+1.21.5"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
# Manually upgrade and pin the next release to 1.21.6.
|
# Manually upgrade and pin the next release to 1.21.6.
|
||||||
@@ -740,7 +745,8 @@ teardown(){
|
|||||||
run sed -i 's/version=0.4.0+1.21.5/version=0.4.1+1.21.6/' "$recipeDir/compose.yml"
|
run sed -i 's/version=0.4.0+1.21.5/version=0.4.1+1.21.6/' "$recipeDir/compose.yml"
|
||||||
assert_success
|
assert_success
|
||||||
_git_commit
|
_git_commit
|
||||||
run git -C "$recipeDir" tag "0.4.1+1.21.6"
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \
|
||||||
|
-a "0.4.1+1.21.6" -m "fake: 0.4.1+1.21.6"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
# Deploy recipe 0.4.0 with the exact pinned 1.21.5 image.
|
# Deploy recipe 0.4.0 with the exact pinned 1.21.5 image.
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ teardown(){
|
|||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' \
|
_inspect_env_test_app
|
||||||
$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "$TEST_RECIIPE:0.1.0+1.20.0"
|
assert_output --partial "$TEST_RECIIPE:0.1.0+1.20.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,15 +140,22 @@ teardown(){
|
|||||||
_undeploy_app
|
_undeploy_app
|
||||||
|
|
||||||
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
||||||
run docker config create "${sanitisedDomainName}_test_conf_v99" "$ABRA_DIR/recipes/abra-test-recipe/abra.sh"
|
remote_ssh_command=""
|
||||||
assert_success
|
if _is_local;
|
||||||
|
then
|
||||||
|
run docker config create "${sanitisedDomainName}_test_conf_v99" "$ABRA_DIR/recipes/abra-test-recipe/abra.sh"
|
||||||
|
else
|
||||||
|
remote_ssh_command="ssh '$TEST_SERVER'"
|
||||||
|
run cat "$ABRA_DIR/recipes/abra-test-recipe/abra.sh" | ssh "$TEST_SERVER" docker config create "${sanitisedDomainName}_test_conf_v99 -"
|
||||||
|
assert_success
|
||||||
|
fi
|
||||||
|
|
||||||
assert bash -c "docker config ls | grep -q test_conf_v99"
|
assert bash -c "$remote_ssh_command docker config ls | grep -q test_conf_v99"
|
||||||
|
|
||||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
refute bash -c "docker config ls | grep -q test_conf_v99"
|
refute bash -c "$remote_ssh_command docker config ls | grep -q test_conf_v99"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "remove .env file" {
|
@test "remove .env file" {
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ teardown(){
|
|||||||
--no-input
|
--no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' \
|
_inspect_env_test_app
|
||||||
$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "$TEST_RECIIPE:0.1.0+1.20.0"
|
assert_output --partial "$TEST_RECIIPE:0.1.0+1.20.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ teardown(){
|
|||||||
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' \
|
_inspect_env_test_app
|
||||||
$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "$TEST_RECIIPE:0.2.0+1.21.0"
|
assert_output --partial "$TEST_RECIPE:0.2.0+1.21.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,18 @@ _ensure_ssh_agent() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
|
if [[ ! -v SSH_AUTH_SOCK ]]; then
|
||||||
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
|
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
|
||||||
eval `ssh-agent`
|
eval `ssh-agent`
|
||||||
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
|
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_is_local() {
|
||||||
|
if [[ "$TEST_SERVER" == "default" ]];
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_ensure_swarm() {
|
_ensure_swarm() {
|
||||||
if [ "$(docker info | grep Swarm | sed 's/Swarm: //g' | tr -d ' ')" == "inactive" ]; then
|
if [ "$(docker info | grep Swarm | sed 's/Swarm: //g' | tr -d ' ')" == "inactive" ]; then
|
||||||
run docker swarm init --advertise-addr 127.0.0.1:2377
|
run docker swarm init --advertise-addr 127.0.0.1:2377
|
||||||
assert_success
|
assert_success
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $(docker network ls | grep -q 'proxy'); then
|
if ! docker network ls | grep -q 'proxy'; then
|
||||||
run docker network create -d overlay proxy
|
run docker network create -d overlay proxy
|
||||||
assert_success
|
assert_success
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! _is_local;
|
||||||
|
then
|
||||||
|
if [ "$(ssh "$TEST_SERVER" docker info | grep Swarm | sed 's/Swarm: //g' | tr -d ' ')" == "inactive" ]; then
|
||||||
|
run ssh "$TEST_SERVER" docker swarm init --advertise-addr 127.0.0.1:2377
|
||||||
|
assert_success
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ssh "$TEST_SERVER" docker network ls | grep -q 'proxy'; then
|
||||||
|
run ssh "$TEST_SERVER" docker network create -d overlay proxy
|
||||||
|
assert_success
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_inspect_env_test_app() {
|
||||||
|
if _is_local;
|
||||||
|
then
|
||||||
|
containerId="$(docker ps -f name="$TEST_APP_DOMAIN_$TEST_SERVER" -q)"
|
||||||
|
run docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' "$containerId"
|
||||||
|
else
|
||||||
|
containerId="$(ssh "$TEST_SERVER" docker ps -f name="$TEST_APP_DOMAIN" -q)"
|
||||||
|
run ssh "$TEST_SERVER" "docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' '$containerId'"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ teardown(){
|
|||||||
|
|
||||||
run $ABRA recipe upgrade "custom-html" --no-input
|
run $ABRA recipe upgrade "custom-html" --no-input
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial 'can upgrade service: app'
|
|
||||||
|
|
||||||
assert_exists "$ABRA_DIR/recipes/custom-html"
|
assert_exists "$ABRA_DIR/recipes/custom-html"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ teardown(){
|
|||||||
assert bash -c "docker context ls | grep -q $TEST_SERVER"
|
assert bash -c "docker context ls | grep -q $TEST_SERVER"
|
||||||
|
|
||||||
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/$TEST_SERVER")
|
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/$TEST_SERVER")
|
||||||
assert_equal $server_dir_perms "700"
|
assert_equal "$server_dir_perms" "700"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "error if using name and --local together" {
|
@test "error if using name and --local together" {
|
||||||
@@ -43,8 +43,8 @@ teardown(){
|
|||||||
assert bash -c "docker context ls | grep -q default"
|
assert bash -c "docker context ls | grep -q default"
|
||||||
assert_output --partial 'local server successfully added'
|
assert_output --partial 'local server successfully added'
|
||||||
|
|
||||||
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/$TEST_SERVER")
|
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/default")
|
||||||
assert_equal $server_dir_perms "700"
|
assert_equal "$server_dir_perms" "700"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "create local server fails when no docker swarm" {
|
@test "create local server fails when no docker swarm" {
|
||||||
|
|||||||
Reference in New Issue
Block a user