-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a bit of an experiment, but I think it might be useful to have full-tool integration tests that exercise the whole (almost) process of running commands and compares the outputs. Might be useful to catch regressions before we get to the point of rolling out on users' repos. Not sure if this will be fun to maintain+grow or not, but I started with a very minimal test (the equivalent of `fogg init`) to see how it goes.
- Loading branch information
Showing
38 changed files
with
3,458 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.10.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fogg.tf linguist-generated | ||
Makefile linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto-generated by fogg. Do not edit | ||
# Make improvements in fogg, so that everyone can benefit. | ||
|
||
# Compiled files | ||
*.tfstate | ||
*.tfstate.*.backup | ||
*.tfstate.backup | ||
*tfvars | ||
|
||
# Module directory | ||
.terraform/ | ||
|
||
# legacy | ||
.rato_pass | ||
|
||
# Pycharm folder | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
65 changes: 65 additions & 0 deletions
65
integration-tests/minimum/expected/scripts/docker-ssh-forward.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
# copied from https://github.com/uber-common/docker-ssh-agent-forward/blob/master/pinata-ssh-forward.sh | ||
|
||
if ! ssh-add -L >/dev/null; then | ||
echo "Add ssh key(s) to your agent and try again." | ||
echo "This is needed for pulling modules from github." | ||
exit | ||
fi | ||
|
||
IMAGE_NAME=uber/ssh-agent-forward:latest | ||
CONTAINER_NAME=pinata-sshd | ||
VOLUME_NAME=ssh-agent | ||
HOST_PORT=2244 | ||
AUTHORIZED_KEYS=$(ssh-add -L | base64 | tr -d '\n') | ||
KNOWN_HOSTS_FILE=$(mktemp -t dsaf.XXX) | ||
|
||
trap 'rm ${KNOWN_HOSTS_FILE}' EXIT | ||
|
||
docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || true | ||
|
||
docker volume create --name "${VOLUME_NAME}" | ||
|
||
docker run \ | ||
--name "${CONTAINER_NAME}" \ | ||
-e AUTHORIZED_KEYS="${AUTHORIZED_KEYS}" \ | ||
-v ${VOLUME_NAME}:/ssh-agent \ | ||
-d \ | ||
-p "${HOST_PORT}:22" \ | ||
"${IMAGE_NAME}" >/dev/null \ | ||
; | ||
|
||
if [ "${DOCKER_HOST}" ]; then | ||
HOST_IP=$(echo "$DOCKER_HOST" | awk -F '//' '{print $2}' | awk -F ':' '{print $1}') | ||
else | ||
HOST_IP=127.0.0.1 | ||
fi | ||
|
||
# FIXME Find a way to get rid of this additional 1s wait | ||
sleep 1 | ||
while ! nc -z -w5 ${HOST_IP} ${HOST_PORT}; do sleep 0.1; done | ||
|
||
ssh-keyscan -p "${HOST_PORT}" "${HOST_IP}" >"${KNOWN_HOSTS_FILE}" 2>/dev/null | ||
|
||
# show the keys that are being forwarded | ||
ssh \ | ||
-A \ | ||
-o "UserKnownHostsFile=${KNOWN_HOSTS_FILE}" \ | ||
-p "${HOST_PORT}" \ | ||
-S none \ | ||
"root@${HOST_IP}" \ | ||
ssh-add -l | ||
|
||
# keep the agent running | ||
ssh \ | ||
-A \ | ||
-f \ | ||
-o "UserKnownHostsFile=${KNOWN_HOSTS_FILE}" \ | ||
-p "${HOST_PORT}" \ | ||
-S none \ | ||
"root@${HOST_IP}" \ | ||
/ssh-entrypoint.sh | ||
|
||
echo 'Agent forwarding successfully started.' |
5 changes: 5 additions & 0 deletions
5
integration-tests/minimum/expected/scripts/docker-ssh-mount.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# copied from https://raw.githubusercontent.com/uber-common/docker-ssh-agent-forward/master/pinata-ssh-mount.sh | ||
|
||
echo "-v ssh-agent:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent/ssh-agent.sock" |
27 changes: 27 additions & 0 deletions
27
integration-tests/minimum/expected/scripts/install_or_update.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_MGR="$1" | ||
PACKAGE_NAME="$2" | ||
|
||
if [[ -z "$PACKAGE_MGR" ]] || [[ -z "$PACKAGE_NAME" ]]; then | ||
echo "Usage: $0 <package_manager> <package_name>" | ||
exit 1 | ||
fi | ||
|
||
if [ "$PACKAGE_MGR" = "gem" ]; then | ||
if ! gem list | grep "$PACKAGE_NAME "; then | ||
echo "gem $PACKAGE_NAME not installed, installing" | ||
gem install "$PACKAGE_NAME" | ||
elif gem outdated | grep "$PACKAGE_NAME "; then | ||
echo "gem $PACKAGE_NAME out of date, updating" | ||
gem update "$PACKAGE_NAME" | ||
fi | ||
elif [ "$PACKAGE_MGR" = "brew" ]; then | ||
if ! brew list | grep "^$PACKAGE_NAME\$"; then | ||
echo "brew package $PACKAGE_NAME not installed, installing" | ||
brew install "$PACKAGE_NAME" | ||
elif brew outdated | grep "^$PACKAGE_NAME\$"; then | ||
brew upgrade "$PACKAGE_NAME" | ||
fi | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Auto-generated by fogg. Do not edit | ||
# Make improvements in fogg, so that everyone can benefit. | ||
|
||
require 'json' | ||
require 'pp' | ||
|
||
ENVS = %w[] | ||
|
||
d = ENVS.map do |env| | ||
outputs = `cd terraform/envs/#{env}/cloud-env && terraform output -json` | ||
begin | ||
data = JSON.parse(outputs) | ||
cidr = data['vpc_cidr']['value'] | ||
address, prefix_length = cidr.split('/') | ||
pattern = address.split('.')[0..((prefix_length.to_i/8)-1)].join('.') + '.*' | ||
bastion = data['bastion_fqdn']['value'] | ||
[pattern, bastion] | ||
rescue JSON::ParserError => e | ||
puts "Error generating config for env: '#{env}'. Output of terraform json request: \n#{outputs}" | ||
end | ||
end | ||
|
||
print <<-END | ||
# auto-generated by tools/ssh_config | ||
Host * | ||
AddKeysToAgent yes | ||
UseKeychain yes | ||
ForwardAgent yes | ||
|
||
END | ||
d.each do |(pattern, bastion)| | ||
print <<-END | ||
Host #{pattern} | ||
ProxyCommand ssh -q #{bastion} -W %h:%p | ||
|
||
Host #{bastion} | ||
User ec2-user | ||
|
||
END | ||
end |
Oops, something went wrong.