Skip to content

Commit

Permalink
ThingpediaIntegrationTest: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jgd5 committed Jul 14, 2021
1 parent a2a7da0 commit 6df9beb
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- export PATH="`pwd`/geckodriver:$PATH"
- ./tests/thingpedia-integration/setup-integration.sh
script: ./tests/thingpedia-integration/run-integration.sh
after_success: npm run coverage
after_success: cat nyc_output | coveralls
-
name: "NLP Integration Tests"
install:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_website_selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async function testRegister(driver) {
// we're logged in, so we get a nice link to the Settings page
const settingsLink = await driver.wait(
WD.until.elementLocated(WD.By.linkText('Settings')),
30000);
120000);

// let's click it...
await settingsLink.click();
Expand Down
20 changes: 20 additions & 0 deletions tests/thingpedia-integration/k8s/config.d/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,23 @@ SUPPORTED_LANGUAGES:
- it-IT
- zh-CN
- zh-TW
USE_BRAND: stanford

ABOUT_OVERRIDE:
index: stanford/about_index.pug
tos: stanford/about_tos.pug
privacy: stanford/about_privacy.pug

EXTRA_ABOUT_PAGES:
- url: get-almond
view: stanford/about_get_almond.pug
title: "Get Almond"
- url: get-involved
view: stanford/about_get_involved.pug
title: "Get Involved With Almond"

EXTRA_NAVBAR:
- url: https://oval.cs.stanford.edu
title: "OVAL Lab"

DISCOURSE_SSO_REDIRECT: https://discourse.almond.stanford.edu
57 changes: 0 additions & 57 deletions tests/thingpedia-integration/k8s/config.d/stanford.js

This file was deleted.

17 changes: 9 additions & 8 deletions tests/thingpedia-integration/k8s/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ spec:
- name: main
image: localhost/almond-test:latest
imagePullPolicy: IfNotPresent
args: [ "run-frontend", "--k8s"]
command: ["/bin/bash"]
args:
- -c
- |
set -ex
cd /opt/almond-cloud
npx nyc /opt/almond-cloud/tests/thingpedia-integration/k8s/start.sh run-frontend --k8s &
wait $!
while [ 1 ]; do sleep 100; done
env:
- name: NODE_MAX_OLD_SPACE_SIZE
value: "2000"
Expand All @@ -24,10 +32,6 @@ spec:
name: config
readOnly: true
subPath: config.yaml
- mountPath: /etc/almond-cloud/config.d/stanford.js
name: stanford
readOnly: true
subPath: stanford.js
ports:
- containerPort: 8080
name: web
Expand All @@ -52,9 +56,6 @@ spec:
- configMap:
name: almond-config
name: config
- configMap:
name: stanford-config
name: stanford
---
apiVersion: v1
kind: Service
Expand Down
3 changes: 0 additions & 3 deletions tests/thingpedia-integration/k8s/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ configMapGenerator:
- name: almond-config
files:
- config.d/config.yaml
- name: stanford-config
files:
- config.d/stanford.js
24 changes: 16 additions & 8 deletions tests/thingpedia-integration/k8s/shared-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@ spec:
serviceAccountName: default-editor
containers:
- name: "main"
image: localhost/almond-cloud:latest
image: localhost/almond-test:latest
imagePullPolicy: IfNotPresent
command: ["/bin/bash"]
args:
- run-worker
- --thingpedia-url=http://frontend.default.svc.cluster.local:8080/thingpedia
- --nl-server-url=https://nlp-staging.almond.stanford.edu
- --oauth-redirect-origin=http://frontend.default.svc.cluster.local:8080
- --faq-models={}
- --notification-config={}
- --locale=en-US
- -c
- |
set -ex
cd /opt/almond-cloud
npx nyc /opt/almond-cloud/tests/thingpedia-integration/k8s/start.sh run-worker \
--thingpedia-url=http://frontend.default.svc.cluster.local:8080/thingpedia \
--nl-server-url=https://nlp-staging.almond.stanford.edu \
--oauth-redirect-origin=http://frontend.default.svc.cluster.local:8080 \
--faq-models={} \
--notification-config={} \
--locale=en-US \
&
wait $!
while [ 1 ]; do sleep 100; done
workingDir: /srv/thingengine
volumeMounts:
- mountPath: /srv/thingengine
Expand Down
8 changes: 8 additions & 0 deletions tests/thingpedia-integration/k8s/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ex

cd /home/almond-cloud
/opt/almond-cloud/dist/main.js "$@" &
pid=$!
echo $pid > /home/almond-cloud/pid
wait $pid
21 changes: 17 additions & 4 deletions tests/thingpedia-integration/run-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ srcdir=`realpath $srcdir`
cd $srcdir

# Run thingpedia-integration test inside frontend pod
POD=`kubectl get pod -l app=frontend -o jsonpath="{.items[0].metadata.name}"`
kubectl exec $POD -- bash -c "cd /opt/almond-cloud && npx nyc tests/thingpedia-integration/thingpedia-integration.sh"
FRONTEND=`kubectl get pod -l app=frontend -o jsonpath="{.items[0].metadata.name}"`
kubectl exec $FRONTEND -- bash -c "cd /opt/almond-cloud && npx nyc tests/thingpedia-integration/thingpedia-integration.sh"

# Run selenium test on ubuntu with Firefox installed
THINGENGINE_CONFIGDIR=tests/thingpedia-integration/k8s npx nyc ts-node tests/test_website_selenium.js

# Copy coverage outputs from frontend pod
kubectl cp $POD:/opt/almond-cloud/.nyc_output .nyc_output
# Get local nyc output
npx nyc report
npx nyc report --reporter=text-lcov > nyc_output

# kill frontend to generate coverage outputs
kubectl exec $FRONTEND -- bash -c 'kill $(cat /home/almond-cloud/pid)'
sleep 2
kubectl exec $FRONTEND -- bash -c "cd /opt/almond-cloud && npx nyc report"
kubectl exec $FRONTEND -- bash -c "cd /opt/almond-cloud && npx nyc report --reporter=text-lcov" >> nyc_output

# kill backend to generate coverage outputs
kubectl exec shared-backend-0 -- bash -c 'kill $(cat /home/almond-cloud/pid)'
sleep 2
kubectl exec shared-backend-0 -- bash -c "cd /opt/almond-cloud && npx nyc report"
kubectl exec shared-backend-0 -- bash -c "cd /opt/almond-cloud && npx nyc report --reporter=text-lcov" >> nyc_output
4 changes: 2 additions & 2 deletions tests/thingpedia-integration/setup-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ kind create cluster --config=$srcdir/tests/thingpedia-integration/k8s/cluster.ya
kind load docker-image localhost/almond-cloud
kind load docker-image localhost/almond-test
kustomize build $srcdir/tests/thingpedia-integration/k8s/database | kubectl apply -f -
kubectl wait --for=condition=complete job/create-db
kubectl wait --timeout=120s --for=condition=complete job/create-db
kustomize build $srcdir/tests/thingpedia-integration/k8s | kubectl apply -f -
kubectl wait --for=condition=Available deployment/frontend
kubectl wait --timeout=120s --for=condition=Available deployment/frontend

0 comments on commit 6df9beb

Please sign in to comment.