Skip to content

Commit 2f6fc74

Browse files
committed
ci: manual harp deploy test
Signed-off-by: Anupam Kumar <[email protected]>
1 parent 46371dc commit 2f6fc74

File tree

1 file changed

+199
-1
lines changed

1 file changed

+199
-1
lines changed

.github/workflows/tests-deploy.yml

Lines changed: 199 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,13 +1284,211 @@ jobs:
12841284
if: always()
12851285
run: tail -v -n +1 *container.json *.log data/nextcloud.log
12861286

1287+
nc-host-manual-harp-host:
1288+
runs-on: ubuntu-22.04
1289+
name: NC In Host (Manual HaRP-Host network)
1290+
1291+
services:
1292+
postgres:
1293+
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
1294+
ports:
1295+
- 4444:5432/tcp
1296+
env:
1297+
POSTGRES_USER: root
1298+
POSTGRES_PASSWORD: rootpassword
1299+
POSTGRES_DB: nextcloud
1300+
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
1301+
1302+
steps:
1303+
- name: Set app env
1304+
run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
1305+
1306+
- name: Checkout server
1307+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
1308+
with:
1309+
submodules: true
1310+
repository: nextcloud/server
1311+
ref: master
1312+
1313+
- name: Checkout AppAPI
1314+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
1315+
with:
1316+
path: apps/${{ env.APP_NAME }}
1317+
1318+
- name: Set up php 8.3
1319+
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
1320+
with:
1321+
php-version: 8.3
1322+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql, redis
1323+
coverage: none
1324+
ini-file: development
1325+
env:
1326+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1327+
1328+
- name: Check composer file existence
1329+
id: check_composer
1330+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
1331+
with:
1332+
files: apps/${{ env.APP_NAME }}/composer.json
1333+
1334+
- name: Set up dependencies
1335+
if: steps.check_composer.outputs.files_exists == 'true'
1336+
working-directory: apps/${{ env.APP_NAME }}
1337+
run: composer i
1338+
1339+
- name: Set up Nextcloud
1340+
env:
1341+
DB_PORT: 4444
1342+
OC_PASS: password
1343+
run: |
1344+
mkdir data
1345+
./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 \
1346+
--database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
1347+
--admin-user admin --admin-pass admin
1348+
./occ config:system:set loglevel --value=0 --type=integer
1349+
./occ config:system:set debug --value=true --type=boolean
1350+
./occ config:system:set overwrite.cli.url --value http://127.0.0.1 --type=string
1351+
./occ app:enable --force ${{ env.APP_NAME }}
1352+
./occ user:add --password-from-env usr
1353+
1354+
- name: Create HaRP and app container
1355+
run: |
1356+
cat apps/${{ env.APP_NAME }}/tests/simple-nginx-NOT-FOR-PRODUCTION.conf
1357+
docker run \
1358+
-e HP_SHARED_KEY="some_very_secure_password" \
1359+
-e NC_INSTANCE_URL="http://127.0.0.1" \
1360+
-e HP_LOG_LEVEL="debug" \
1361+
-v /var/run/docker.sock:/var/run/docker.sock \
1362+
--net host --name appapi-harp \
1363+
--restart unless-stopped \
1364+
-d ghcr.io/nextcloud/nextcloud-appapi-harp:latest
1365+
docker run --net host --name nextcloud --rm \
1366+
-v $(pwd)/apps/${{ env.APP_NAME }}/tests/simple-nginx-NOT-FOR-PRODUCTION.conf:/etc/nginx/conf.d/default.conf:ro \
1367+
-d nginx
1368+
docker run --net host --name nc_app_app-skeleton-python \
1369+
-e AA_VERSION=4.0.0 \
1370+
-e APP_SECRET=12345 \
1371+
-e APP_ID=app-skeleton-python \
1372+
-e APP_DISPLAY_NAME="App Skeleton" \
1373+
-e APP_VERSION=3.0.1 \
1374+
-e APP_HOST=0.0.0.0 \
1375+
-e APP_PORT=23000 \
1376+
-e NEXTCLOUD_URL=http://127.0.0.1 \
1377+
--rm -d ghcr.io/nextcloud/app-skeleton-python:latest
1378+
1379+
- name: Test deploy
1380+
run: |
1381+
set -x
1382+
PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8080 &
1383+
./occ app_api:daemon:register \
1384+
manual_install_harp "Harp Manual Install" "manual-install" "http" "127.0.0.1:8780" "http://127.0.0.1" \
1385+
--net host --harp --harp_frp_address "127.0.0.1:8782" --harp_shared_key "some_very_secure_password"
1386+
./occ app_api:daemon:list
1387+
1388+
./occ app_api:app:register app-skeleton-python manual_install_harp \
1389+
--json-info " \
1390+
{ \
1391+
\"id\": \"app-skeleton-python\", \
1392+
\"name\": \"App Skeleton\", \
1393+
\"daemon_config_name\": \"manual_install_harp\", \
1394+
\"version\": \"3.0.1\", \
1395+
\"secret\": \"12345\", \
1396+
\"port\": 23000, \
1397+
\"routes\": [ \
1398+
{ \
1399+
\"url\": \"^/public$\", \
1400+
\"verb\": \"GET\", \
1401+
\"access_level\": 0 \
1402+
}, \
1403+
{ \
1404+
\"url\": \"^/user$\", \
1405+
\"verb\": \"GET\", \
1406+
\"access_level\": 1 \
1407+
}, \
1408+
{ \
1409+
\"url\": \"^/admin$\", \
1410+
\"verb\": \"GET\", \
1411+
\"access_level\": 2 \
1412+
}, \
1413+
{ \
1414+
\"url\": \"^/$\", \
1415+
\"verb\": \"GET\", \
1416+
\"access_level\": 1 \
1417+
}, \
1418+
{ \
1419+
\"url\": \"^/ws$\", \
1420+
\"verb\": \"GET\", \
1421+
\"access_level\": 1 \
1422+
} \
1423+
] \
1424+
}" \
1425+
--wait-finish
1426+
1427+
function test_req() {
1428+
temp=$(mktemp)
1429+
curl -i -o $temp -w "%{http_code}" $2 http://127.0.0.1/exapps/app-skeleton-python/$1 | grep -q "$3" || {
1430+
echo "$1 :: $2 :: $3"
1431+
cat $temp
1432+
error
1433+
}
1434+
echo -e "\n\n-------------------------\n$1 :: $2 :: $3\n" | tee -a curl.log
1435+
cat $temp | tee -a curl.log
1436+
}
1437+
1438+
test_req public "--" 200
1439+
test_req public "-u usr:password" 200
1440+
test_req public "-u admin:admin" 200
1441+
1442+
test_req user "--" 403
1443+
test_req user "-u usr:password" 200
1444+
test_req user "-u admin:admin" 200
1445+
1446+
test_req admin "--" 403
1447+
test_req admin "-u usr:password" 403
1448+
test_req admin "-u admin:admin" 200
1449+
1450+
# clients get blacklisted for 5 bad requests for 5 minutes
1451+
sleep 301
1452+
1453+
test_req imaginary "--" 404
1454+
test_req imaginary "-u usr:password" 404
1455+
test_req imaginary "-u admin:admin" 404
1456+
1457+
./occ app_api:app:disable app-skeleton-python
1458+
1459+
- name: Check logs
1460+
run: |
1461+
grep -q 'Hello from app-skeleton-python :)' data/nextcloud.log || error
1462+
grep -q 'Bye bye from app-skeleton-python :(' data/nextcloud.log || error
1463+
1464+
- name: Save app and HaRP container info & logs
1465+
if: always()
1466+
run: |
1467+
docker inspect appapi-harp | json_pp > harp_host_container.json
1468+
docker logs appapi-harp > harp_host_container.log 2>&1
1469+
docker inspect nc_app_app-skeleton-python | json_pp > app_host_container.json
1470+
docker logs nc_app_app-skeleton-python > app_host_container.log 2>&1
1471+
1472+
- name: Unregister Skeleton & Daemon
1473+
run: |
1474+
./occ app_api:app:unregister app-skeleton-python
1475+
./occ app_api:daemon:unregister manual_install_harp
1476+
1477+
- name: Test OCC commands(docker)
1478+
run: python3 apps/${{ env.APP_NAME }}/tests/test_occ_commands_docker.py
1479+
1480+
- name: Show all logs
1481+
if: always()
1482+
run: tail -v -n +1 *container.json *.log data/nextcloud.log
1483+
12871484
tests-deploy-success:
12881485
permissions:
12891486
contents: none
12901487
runs-on: ubuntu-22.04
12911488
needs: [nc-host-app-docker, nc-docker-app-docker, nc-docker-dsp-http,
12921489
nc-docker-dsp-https, nc-host-app-docker-redis, nc-host-network-host,
1293-
nc-docker-harp-bridge, nc-docker-harp-bridge-no-tls, nc-host-harp-host]
1490+
nc-docker-harp-bridge, nc-docker-harp-bridge-no-tls, nc-host-harp-host,
1491+
nc-host-manual-harp-host]
12941492
name: Tests-Deploy-OK
12951493
steps:
12961494
- run: echo "Tests-Deploy passed successfully"

0 commit comments

Comments
 (0)