Skip to content

Commit

Permalink
fuzzbucket ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Gartland committed Sep 12, 2023
1 parent 06ae1a8 commit 6282eaf
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 17 deletions.
33 changes: 23 additions & 10 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,11 @@ jobs:
env:
os: windows-latest
DOCKER: "false"
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
just web/build-and-test-ci-e2e $env:os
just test/init-connect $env:os
test-macos:
Expand Down Expand Up @@ -450,8 +453,11 @@ jobs:
env:
os: macos-latest
DOCKER: "false"
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
just web/build-and-test-ci-e2e ${os}
just test/init-connect ${os}
build-linux-amd64:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -561,6 +567,9 @@ jobs:
env:
os: linux-amd64
DOCKER: "false"
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
just test/ui-client ${os}
Expand Down Expand Up @@ -677,11 +686,15 @@ jobs:
os: linux-arm64
run: |
just test/run-client ${os}
# -
# name: Run linux-arm64 Cypress Tests
# env:
# os: linux-arm64
# DOCKER: "false"
# run: |
# just web/build && \
# just test/ui-client ${os}
-
name: Run linux-arm64 Cypress Tests
env:
os: linux-arm64
DOCKER: "false"
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}

run: |
just web/build && \
just test/ui-client ${os}
5 changes: 2 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,10 @@ start-agent-for-e2e:
GOARCH="${GOARCH%%[[:cntrl:]]}"

echo "Working directory is $(pwd)"
echo "COMMAND ARGS: ${CMD_ARGS}"

./bin/$GOOS-$GOARCH/connect-client publish-ui \
./test/sample-content/fastapi-simple \
--listen=127.0.0.1:9000 \
--token=abc123
${CMD_ARGS}

[private]
_with_docker *args:
Expand Down
1 change: 1 addition & 0 deletions test/environments/.basic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CMD_ARGS="./test/sample-content/fastapi-simple --listen=localhost:9000 --token=abc123 -n connect"
5 changes: 2 additions & 3 deletions test/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ init-connect target:
echo "${FUZZBUCKET_SSH_KEY}" > .fuzzbucket-ssh-key
chmod 600 .fuzzbucket-ssh-key
export SSH_OPTIONS="-i.fuzzbucket-ssh-key"
export CONNECT_VERSION=$(curl https://cdn.posit.co/connect/latest-packages.json |
jq ".packages[0].version")
export CONNECT_IP="$(python setup/connect-setup.py)"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$CONNECT_IP "${SSH_OPTIONS}" sudo -E UNATTENDED=1 bash installer-ci.sh ${CONNECT_VERSION}
python setup/client-setup.py
source ./environments/.basic && \
export CMD_ARGS="$CMD_ARGS" && \
just ../web/build-and-test-ci-e2e {{target}}
run-client target:
Expand Down
34 changes: 34 additions & 0 deletions test/setup/connect-setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
import hashlib
import subprocess
import json
import requests
import time
import logging

# use the perftest fuzzbucket instance since it already has all the deps
alias = "perftest-connect-20230518"
box_name = "connect-ci"
list_command = "fuzzbucket-client -j list"
create_command = "fuzzbucket-client create -c " + alias + " -n " + box_name
remove_command = "fuzzbucket-client rm " + box_name
ssh_options = "-i.fuzzbucket-ssh-key"
# connect_version = $(curl https://cdn.posit.co/connect/latest-packages.json |
# jq ".packages[0].version")


def get_api_key(username):
# Calculate the MD5 hash for the username to get an API Key
api_key = hashlib.md5(username.encode()).hexdigest()
return api_key

def get_latest_connect_version():
response = requests.get("https://cdn.posit.co/connect/latest-packages.json")
latest_connect = response.json()['packages'][0]['version']
return latest_connect

def get_current_connect_version(connect_ip, api_key):
response = requests.get(
'http://' + connect_ip + ':3939/__api__/server_settings',
headers={'Authorization': 'Key ' + api_key},
)
current_connect = response.json()['version']
return current_connect

def check_existing_boxes(box_name):
output = subprocess.check_output(list_command, shell=True, text=True)
Expand All @@ -31,8 +56,12 @@ def connect_ready(box_name, max_attempts, interval):
attempts = 0
while attempts < max_attempts:
try:
logging.info("Checking Connect Status")
response = requests.get("http://"+connect_box+":3939/__ping__")
if response.status_code == 200:
if latest_connect != current_connect:
logging.info("Installing Connect...")
subprocess.check_output(install_connect, shell=True, text=True)
return response.text
except requests.RequestException:
pass
Expand All @@ -41,6 +70,11 @@ def connect_ready(box_name, max_attempts, interval):
attempts += 1
return None

api_key=get_api_key('admin')
latest_connect=get_latest_connect_version()
current_connect=get_current_connect_version(get_ip(box_name), api_key)
install_connect = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@" + get_ip(box_name) + " " + ssh_options + " sudo -E UNATTENDED=1 bash installer-ci.sh " + latest_connect

response = connect_ready(box_name, 20, 5)

if response:
Expand Down
1 change: 1 addition & 0 deletions web/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ build-and-test-ci-e2e target:
# cache within root's home dir.
# use a different cache per os
export CYPRESS_CACHE_FOLDER="./cypress/{{target}}/.cache"
export CYPRESS_CONNECT_ADDRESS="http://$CONNECT_IP:3939/connect/\#/login"
# install cypress
npx cypress install

Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:e2e:ci": "start-server-and-test --expect 401 'just ../start-agent-for-e2e' http-get://127.0.0.1:9000 cypress:run:ci",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:run:ci": "cypress run --env publishing-token=abc123"
"cypress:run:ci": "cypress run --env publishing-token=abc123,CYPRESS_CONNECT_ADDRESS=$CYPRESS_CONNECT_ADDRESS"
},
"dependencies": {
"@quasar/extras": "^1.16.5",
Expand Down

0 comments on commit 6282eaf

Please sign in to comment.