diff --git a/.travis.yml b/.travis.yml index 2decc36c5..1456d1af4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/tests/test_website_selenium.js b/tests/test_website_selenium.js index be14cd444..09d8e6c90 100644 --- a/tests/test_website_selenium.js +++ b/tests/test_website_selenium.js @@ -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(); diff --git a/tests/thingpedia-integration/k8s/config.d/config.yaml b/tests/thingpedia-integration/k8s/config.d/config.yaml index b3e46cb62..5a8b56eaf 100644 --- a/tests/thingpedia-integration/k8s/config.d/config.yaml +++ b/tests/thingpedia-integration/k8s/config.d/config.yaml @@ -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 \ No newline at end of file diff --git a/tests/thingpedia-integration/k8s/config.d/stanford.js b/tests/thingpedia-integration/k8s/config.d/stanford.js deleted file mode 100644 index 9dbeea434..000000000 --- a/tests/thingpedia-integration/k8s/config.d/stanford.js +++ /dev/null @@ -1,57 +0,0 @@ -// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*- -// -// This file is part of Almond -// -// Copyright 2018-2020 The Board of Trustees of the Leland Stanford Junior University -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author: Giovanni Campagna - -// OVAL specific configuration for Web Almond - -// overrides the about pages to point to our website, adds the research -// and get-almond page - -// gettext marker -function _(x) { return x; } - -module.exports.USE_BRAND = 'stanford'; - -module.exports.ABOUT_OVERRIDE = { - index: 'stanford/about_index.pug', - tos: 'stanford/about_tos.pug', - privacy: 'stanford/about_privacy.pug' -}; - -module.exports.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") - }, -]; - -module.exports.EXTRA_NAVBAR = [ - { - url: 'https://oval.cs.stanford.edu', - title: _("OVAL Lab"), - }, -]; - -module.exports.DISCOURSE_SSO_REDIRECT = 'https://discourse.almond.stanford.edu'; diff --git a/tests/thingpedia-integration/k8s/frontend.yaml b/tests/thingpedia-integration/k8s/frontend.yaml index 274b434fb..88b31d27a 100644 --- a/tests/thingpedia-integration/k8s/frontend.yaml +++ b/tests/thingpedia-integration/k8s/frontend.yaml @@ -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" @@ -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 @@ -52,9 +56,6 @@ spec: - configMap: name: almond-config name: config - - configMap: - name: stanford-config - name: stanford --- apiVersion: v1 kind: Service diff --git a/tests/thingpedia-integration/k8s/kustomization.yaml b/tests/thingpedia-integration/k8s/kustomization.yaml index 8fb92f63c..435022d42 100644 --- a/tests/thingpedia-integration/k8s/kustomization.yaml +++ b/tests/thingpedia-integration/k8s/kustomization.yaml @@ -14,6 +14,3 @@ configMapGenerator: - name: almond-config files: - config.d/config.yaml -- name: stanford-config - files: - - config.d/stanford.js diff --git a/tests/thingpedia-integration/k8s/shared-backend.yaml b/tests/thingpedia-integration/k8s/shared-backend.yaml index 0b3fed396..23e2a51ed 100644 --- a/tests/thingpedia-integration/k8s/shared-backend.yaml +++ b/tests/thingpedia-integration/k8s/shared-backend.yaml @@ -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 diff --git a/tests/thingpedia-integration/k8s/start.sh b/tests/thingpedia-integration/k8s/start.sh new file mode 100755 index 000000000..a392eada4 --- /dev/null +++ b/tests/thingpedia-integration/k8s/start.sh @@ -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 \ No newline at end of file diff --git a/tests/thingpedia-integration/run-integration.sh b/tests/thingpedia-integration/run-integration.sh index 18baf4d8d..733d8a10c 100755 --- a/tests/thingpedia-integration/run-integration.sh +++ b/tests/thingpedia-integration/run-integration.sh @@ -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 diff --git a/tests/thingpedia-integration/setup-integration.sh b/tests/thingpedia-integration/setup-integration.sh index 0d109444d..0ff4583c1 100755 --- a/tests/thingpedia-integration/setup-integration.sh +++ b/tests/thingpedia-integration/setup-integration.sh @@ -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 \ No newline at end of file +kubectl wait --timeout=120s --for=condition=Available deployment/frontend \ No newline at end of file