Skip to content

Commit

Permalink
E2E test for inventory update on client firstboot (#128)
Browse files Browse the repository at this point in the history
* added check for inventory being added

* cancel genisys server if meteor does not launch

* preserve environment when launching genisys server
  • Loading branch information
xeluior authored Apr 19, 2024
1 parent 66024a6 commit 32b04d5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions genisys/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def meteor_initialization(server_config: ServerOptions):
os.environ['PORT'] = '8080'

if 'MONGO_URL' not in os.environ:
print('MONGO_URL not found in environment variables, cancelling Meteor server.')
return
raise ValueError('MONGO_URL not found in environment variables, cancelling Meteor server.')
print('MONGO_URL found.')

if 'CONFIG_FILE' not in os.environ:
Expand Down
7 changes: 5 additions & 2 deletions tests/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ if [ ! -r "${HOST_SSH_KEY}" ]; then
echo 'You do not appear to be in the genisys repo. Please run this script from the git root.'
exit 1
fi
chmod 0600 "${HOST_SSH_KEY}"
chmod 600 "${HOST_SSH_KEY}"
chmod 644 "${HOST_SSH_KEY}.pub"
chmod 700 "$(dirname "${HOST_SSH_KEY}")"

# build the package
mkdir -p "${SHARED_FOLDER}"
Expand Down Expand Up @@ -149,7 +151,7 @@ host-ssh() {
while ! host-ssh echo 'Connected' 2>/dev/null; do :; done

# install the package
host-ssh /app/setup.sh
host-ssh <"${SHARED_FOLDER}/setup.sh"

# setup the client VM
"${VBOXMANAGE}" createvm \
Expand Down Expand Up @@ -188,3 +190,4 @@ host-ssh /app/setup.sh
"${VBOXMANAGE}" startvm "${CLIENT_VMNAME}" \
--type='headless'

host-ssh <"${SHARED_FOLDER}/expect.sh"
8 changes: 8 additions & 0 deletions tests/scripts/tests/inventory/expect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
export CONFIG_FILE=/app/data/config.yaml
export MONGO_URL=mongodb://localhost:3000/local

sudo -E genisys server -f $CONFIG_FILE &
mongosh $MONGO_URL --eval 'while (db["ClientsCollection"].findOne() == null); console.log("Client Added")'
sudo killall genisys
exit 0
4 changes: 2 additions & 2 deletions tests/scripts/tests/inventory/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
CONFIG_FILE=/app/data/config.yaml
MONGO_URL=mongodb://localhost:3000/local
SRV_USR=genisys
SRV_DIR=/var/$SRV_USR
HOSTS=$SRV_DIR/hosts.json
Expand All @@ -8,5 +10,3 @@ sudo pip install /app/genisys-0.1.0-py3-none-any.whl
sudo genisys install --file $CONFIG_FILE
sudo touch $HOSTS
sudo chown $SRV_USR:$SRV_USR $HOSTS
sudo genisys server -f $CONFIG_FILE & disown -h

0 comments on commit 32b04d5

Please sign in to comment.