Skip to content

Commit e2375e5

Browse files
authored
Get tests running with qa users (#834)
* merge in new auth token and some qa users * update tests to use new users from config * get current tests to pass with new qa users * change dev to qa for thurloe url * Save screenshot on test failure. * udpate ctmpls * put / in front of chrome path * add pem ctmpl and fix template render stuff * documentation for automation * fix failure screenshot rendering * Added clean-up to registration test and migrated it to the new test users. Added passing of FireCloud-Id to Thurloe calls. Fixed a bug with xpath of checking for an element with text. * don't use ivy cache * add dsde-toolbox pull to runtests script * Added Thurloe service * changing local orch api * use different auth domain * get default auth domain from vault * add host name to test runner * fixed loading of particpants.txt for DataTabSpec * fail whole script if tests fail * Improved reliability of test for creating a billing project. Don't hide the test failure if there is a problem capturing a screenshot. Avoid stalled headless chrome nodes (SeleniumHQ/docker-selenium#87). * Re-throw error when logging. Be a little more quiet about clean-up failures. * Avoid instability with Google sign-in when the popup window automatically closes.
1 parent 9b38177 commit e2375e5

37 files changed

+588
-285
lines changed

Dockerfile-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ COPY build.sbt /app
99

1010
WORKDIR /app
1111

12-
CMD bash test.sh
12+
CMD bash test.sh

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,28 @@ To compile and build the `broadinstitute/firecloud-ui` docker image, run
6868
```
6969
./script/build.sh compile -d build
7070
```
71+
72+
## Selenium tests
73+
74+
Selenium tests are found in the `automation` directory. They should run against a firecloud-in-a-box (FiaB).
75+
76+
### Running with docker
77+
78+
First build the docker image
79+
```
80+
docker build -f Dockerfile-tests -t automation .
81+
```
82+
83+
Then run the run-tests script with the newly created image. This script will render the `application.conf` and `firecloud-account.pem` from vault to be used by the test container. Note that if you are running outside of docker you will need to generate these files manually.
84+
```
85+
cd automation/docker
86+
./run-tests.sh 4 qa <ip of FiaB>
87+
```
88+
89+
### Running locally
90+
Note that you will need to render `automation/docker/application.conf.ctmpl` and copy it to `automation/src/resources/`, as well as `automation/src/firecloud-account.pem.ctmpl`, which should be saved in `/etc`.
91+
Your local `/etc/hosts` file will need to be configured so that Firecloud DNS names are pointing to the IP of your running FiaB. For more
92+
```
93+
sbt test -Djsse.enableSNIExtension=false -Dheadless=false
94+
sbt clean
95+
```
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
{{with $environment := env "ENVIRONMENT"}}
2-
{{with $accounts := vault (printf "secret/dsde/%s/colvin/accounts" $environment)}}
3-
firecloud {
4-
baseUrl = "http://firecloud-fiab.dsde-{{$environment}}.broadinstitute.org/"
5-
apiUrl = "https://firecloud-fiab.dsde-{{$environment}}.broadinstitute.org:23443/"
6-
rawlsApiUrl = "https://firecloud-fiab.dsde-{{$environment}}.broadinstitute.org:24443"
2+
{{with $hostName := env "HOST_NAME"}}
3+
{{with $users := vault (printf "secret/dsde/firecloud/%s/common/users" $environment)}}
4+
{{with $secrets := vault (printf "secret/dsde/firecloud/%s/common/secrets" $environment)}}
5+
{{with $authDomain := vault (printf "secret/dsde/firecloud/%s/common/hosts/%s" $environment $hostName)}}
6+
fireCloud {
7+
baseUrl = "https://firecloud-fiab.dsde-{{$environment}}.broadinstitute.org:22443/"
8+
orchApiUrl = "https://firecloud-orchestration-fiab.dsde-{{$environment}}.broadinstitute.org:23443/"
9+
rawlsApiUrl = "https://rawls.dsde-{{$environment}}.broadinstitute.org:24443/"
10+
thurloeApiUrl = "https://thurloe.dsde-{{$environment}}.broadinstitute.org:25443/"
11+
fireCloudId = "{{$secrets.Data.firecloud_id}}"
12+
authDomain = "{{$authDomain.Data.auth_domain}}"
713
}
814

9-
accounts {
10-
notSoSecretPassword = "{{$accounts.Data.testreg_password}}"
15+
gcs {
16+
serviceProject = "broad-dsde-{{$environment}}"
17+
qaEmail = "{{$users.Data.service_acct_email}}"
18+
qaPemFile = "/app/automation/src/test/resources/firecloud-qa.pem"
19+
billingAccount = "{{$users.Data.billing_acct}}"
1120
}
1221

13-
authTokens {
14-
admin = ""
15-
elvin = ""
16-
testFireC = ""
22+
users {
23+
notSoSecretPassword = "{{$users.Data.users_passwd}}"
24+
{{$users.Data.users}}
1725
}
1826

1927
chromeSettings {
2028
chromedriverHost = "http://hub:4444/wd/hub"
29+
chromedriverPath = "/usr/local/bin/chromedriver"
2130
}
2231
{{end}}
32+
{{end}}
33+
{{end}}
34+
{{end}}
2335
{{end}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{with $environment := env "ENVIRONMENT"}}{{with $pemFile := vault (printf "secret/dsde/firecloud/%s/common/firecloud-account.pem" $environment)}}
2+
{{$pemFile.Data.private_key}}
3+
{{end}}{{end}}

automation/docker/hub-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
environment:
2020
HUB_PORT_4444_TCP_ADDR: hub
2121
HUB_PORT_4444_TCP_PORT: 4444
22+
DBUS_SESSION_BUS_ADDRESS: /dev/null
2223
extra_hosts:
2324
- "firecloud-fiab.dsde-$ENV.broadinstitute.org:$DOCKERHOST"
2425
- "firecloud-orchestration-fiab.dsde-$ENV.broadinstitute.org:$DOCKERHOST"

automation/docker/run-tests.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ DOCKERHOST=${3:-$DOCKERHOST}
1313
export DOCKERHOST=$DOCKERHOST
1414
TEST_CONTAINER=${4:-automation}
1515
VAULT_TOKEN=$5
16+
HOST_NAME=$6
17+
WORKING_DIR=${7:-$PWD}
1618

17-
if [ -z VAULT_TOKEN ]; then
19+
if [ -z $VAULT_TOKEN ]; then
1820
VAULT_TOKEN=$(cat ~/.vault-token)
1921
fi
2022

@@ -40,6 +42,7 @@ startup() {
4042
echo "Tests are already running on this host. Kill current tests or try again later."
4143
exit 1
4244
fi
45+
rm -rf $WORKING_DIR/target/ $WORKING_DIR/failure_screenshots/
4346
}
4447
# kill and remove any running containers
4548
cleanup () {
@@ -60,21 +63,24 @@ docker-compose -f hub-compose.yml up -d
6063
docker-compose -f hub-compose.yml scale chrome=$NUM_NODES
6164

6265
# render ctmpls
63-
docker run --rm -e VAULT_TOKEN=${VAULT_TOKEN} \
64-
-e ENVIRONMENT=${ENV} -v $(pwd):/working \
65-
broadinstitute/dsde-toolbox:dev consul-template \
66-
-config=/etc/consul-template/config/config.json \
67-
-template=application.conf.ctmpl:application.conf \
68-
-once
66+
docker pull broadinstitute/dsde-toolbox:dev
67+
docker run --rm -e VAULT_TOKEN=${VAULT_TOKEN} -e HOST_NAME=${HOST_NAME} \
68+
-e ENVIRONMENT=${ENV} -v ${WORKING_DIR}:/working \
69+
-e OUT_PATH=/working/target -e INPUT_PATH=/working \
70+
broadinstitute/dsde-toolbox:dev render-templates.sh
6971

7072
# run tests
7173
docker run -e DOCKERHOST=$DOCKERHOST \
7274
--net=docker_default \
7375
-e ENV=$ENV \
7476
--add-host=firecloud-fiab.dsde-${ENV}.broadinstitute.org:${DOCKERHOST} \
7577
--add-host=firecloud-orchestration-fiab.dsde-${ENV}.broadinstitute.org:${DOCKERHOST} \
78+
--add-host=rawls.dsde-${ENV}.broadinstitute.org:${DOCKERHOST} \
79+
--add-host=thurloe.dsde-${ENV}.broadinstitute.org:${DOCKERHOST} \
7680
-P --rm -t -e CHROME_URL="http://hub:4444/" \
77-
-v $PWD/application.conf:/app/automation/src/test/resources/application.conf \
81+
-v $WORKING_DIR/target/application.conf:/app/automation/src/test/resources/application.conf \
82+
-v $WORKING_DIR/target/firecloud-account.pem:/app/automation/src/test/resources/firecloud-${ENV}.pem \
83+
-v $WORKING_DIR/failure_screenshots:/app/failure_screenshots \
7884
-v jar-cache:/root/.ivy -v jar-cache:/root/.ivy2 \
7985
--link docker_hub_1:hub --name ${TEST_CONTAINER} -w /app \
8086
${TEST_CONTAINER}:latest
Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
fireCloud {
2-
baseUrl = "http://local.broadinstitute.org/"
3-
apiUrl = "https://firecloud-fiab.dsde-dev.broadinstitute.org:23443/"
4-
rawlsApiUrl = "https://firecloud-fiab.dsde-dev.broadinstitute.org:24443/"
2+
baseUrl = "https://firecloud-fiab.dsde-qa.broadinstitute.org:22443/"
3+
apiUrl = "https://firecloud-fiab.dsde-qa.broadinstitute.org:23443/"
4+
rawlsApiUrl = "https://firecloud-fiab.dsde-qa.broadinstitute.org:24443/"
5+
thurloeApiUrl = "https://firecloud-fiab.dsde-qa.broadinstitute.org:25443/"
56
}
67

7-
accounts {
8-
notSoSecretPassword = ""
8+
gcs {
9+
serviceProject = "broad-dsde-qa"
10+
qaEmail = "[email protected]"
11+
qaPemFile = "/app/automation/src/test/resources/firecloud-qa.pem"
12+
billingAccount = "Broad Institute - 4140002"
913
}
1014

11-
authTokens {
12-
admin = ""
13-
elvin = ""
14-
testFireC = ""
15+
users {
16+
notSoSecretPassword = "alohomora"
17+
dumbledore = "[email protected]"
18+
voldemort = "[email protected]"
19+
20+
mcgonagall = "[email protected]"
21+
hermione = "[email protected]"
22+
23+
24+
25+
26+
george = "[email protected]"
27+
28+
hermione = "[email protected]"
29+
# following users only used to test user creation
30+
31+
neville = "[email protected]"
1532
}
1633

1734
chromeSettings {
1835
chromedriverHost = "http://hub:4444/wd/hub"
19-
}
36+
chromedriverPath = "/usr/local/bin/chromedriver"
37+
}
38+
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.broadinstitute.dsde.firecloud.auth.AuthTokens
12
import org.broadinstitute.dsde.firecloud.pages.{WebBrowserSpec, WorkspaceDataPage}
23
import org.broadinstitute.dsde.firecloud.{CleanUp, Config, WebBrowserUtil}
34
import org.scalatest.selenium.WebBrowser
@@ -8,18 +9,19 @@ class DataTabSpec extends FlatSpec with WebBrowserSpec with ParallelTestExecutio
89
behavior of "Data"
910

1011
it should "import a participants file" in withWebDriver { implicit driver =>
11-
val url = getClass.getResource("org/broadinstitute/dsde/firecloud/data/participants.txt")
12+
val filename = "automation/src/test/resources/participants.txt"
1213

13-
val billingProject = "broad-dsde-dev"
14+
val billingProject = Config.Projects.default
1415
val wsName = "TestSpec_FireCloud_import_participants_file_" + randomUuid
15-
implicit val authToken = Config.AuthTokens.testFireC
16+
implicit val authToken = AuthTokens.testUser
1617
api.workspaces.create(billingProject, wsName)
1718
register cleanUp api.workspaces.delete(billingProject, wsName)
1819

19-
val workspaceListPage = signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
20+
val workspaceListPage = signIn(Config.Users.testUser.email, Config.Users.testUser.password)
2021
val workspaceDataTab = new WorkspaceDataPage(billingProject, wsName).open
21-
workspaceDataTab.importFile(url.getPath)
22+
workspaceDataTab.importFile(filename)
2223
assert(workspaceDataTab.getNumberOfParticipants() == 1)
24+
2325
//more checks should be added here
2426
}
2527
}

automation/src/test/scala/MethodConfigTabSpec.scala

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import java.util.UUID
22

3+
import org.broadinstitute.dsde.firecloud.auth.{AuthToken, AuthTokens, Credentials}
34
import org.broadinstitute.dsde.firecloud.data.TestData
45
import org.broadinstitute.dsde.firecloud.pages.{WebBrowserSpec, WorkspaceListPage, WorkspaceMethodConfigPage}
56
import org.broadinstitute.dsde.firecloud.{CleanUp, Config}
67
import org.scalatest._
78

89
class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
910

10-
val billingProject = "broad-dsde-dev"
11-
val methodConfigName = "test_method" + UUID.randomUUID().toString
12-
val wrongRootEntityErrorText = "Error: Method configuration expects an entity of type sample, but you gave us an entity of type participant."
13-
val noExpressionErrorText = "Error: Method configuration expects an entity of type sample, but you gave us an entity of type sample_set."
11+
val billingProject: String = Config.Projects.default
12+
val methodConfigName: String = "test_method" + UUID.randomUUID().toString
13+
val wrongRootEntityErrorText: String = "Error: Method configuration expects an entity of type sample, but you gave us an entity of type participant."
14+
val noExpressionErrorText: String = "Error: Method configuration expects an entity of type sample, but you gave us an entity of type sample_set."
1415

16+
implicit val authToken: AuthToken = AuthTokens.hermione
17+
val uiUser: Credentials = Config.Users.hermione
1518

1619
"launch a simple workflow" in withWebDriver { implicit driver =>
1720
val wsName = "TestSpec_FireCloud_launch_a_simple_workflow" + UUID.randomUUID.toString
18-
implicit val authToken = Config.AuthTokens.testFireC
1921
api.workspaces.create(billingProject, wsName)
2022
register cleanUp api.workspaces.delete(billingProject, wsName)
2123
api.importMetaData(billingProject, wsName, "entities", TestData.SingleParticipant.participantEntity)
2224

23-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
25+
signIn(uiUser)
2426
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName).open
2527
val methodConfigDetailsPage = workspaceMethodConfigPage.importMethodConfig(TestData.SimpleMethodConfig.namespace,
2628
TestData.SimpleMethodConfig.name, TestData.SimpleMethodConfig.snapshotId, methodConfigName, TestData.SimpleMethodConfig.rootEntityType)
@@ -33,12 +35,11 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
3335

3436
"launch modal with no default entities" in withWebDriver { implicit driver =>
3537
val wsName = "TestSpec_FireCloud_launch_modal_no_default_entities" + UUID.randomUUID.toString
36-
implicit val authToken = Config.AuthTokens.testFireC
3738
api.workspaces.create(billingProject, wsName)
3839
register cleanUp api.workspaces.delete(billingProject, wsName)
3940
api.importMetaData(billingProject, wsName, "entities", TestData.SingleParticipant.participantEntity)
4041

41-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
42+
signIn(uiUser)
4243
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName)
4344
workspaceMethodConfigPage.open
4445
val methodConfigDetailsPage = workspaceMethodConfigPage.importMethodConfig(TestData.SimpleMethodConfig.namespace,
@@ -51,7 +52,6 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
5152

5253
"launch modal with workflows warning" in withWebDriver { implicit driver =>
5354
val wsName = "TestSpec_FireCloud_launch_modal_with_workflows_warning" + UUID.randomUUID.toString
54-
implicit val authToken = Config.AuthTokens.testFireC
5555
api.workspaces.create(billingProject, wsName)
5656
register cleanUp api.workspaces.delete(billingProject, wsName)
5757

@@ -60,7 +60,7 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
6060
api.importMetaData(billingProject, wsName, "entities", TestData.HundredAndOneSampleSet.sampleSetCreation)
6161
api.importMetaData(billingProject, wsName, "entities", TestData.HundredAndOneSampleSet.sampleSetMembership)
6262

63-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
63+
signIn(uiUser)
6464
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName)
6565
workspaceMethodConfigPage.open
6666
val methodConfigDetailsPage = workspaceMethodConfigPage.importMethodConfig(TestData.SimpleMethodConfig.namespace,
@@ -76,12 +76,11 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
7676

7777
"launch workflow with wrong root entity" in withWebDriver { implicit driver =>
7878
val wsName = "TestSpec_FireCloud_launch_workflow_with_wrong_root_entity" + UUID.randomUUID.toString
79-
implicit val authToken = Config.AuthTokens.testFireC
8079
api.workspaces.create(billingProject, wsName)
8180
register cleanUp api.workspaces.delete(billingProject, wsName)
8281
api.importMetaData(billingProject, wsName, "entities", TestData.SingleParticipant.participantEntity)
8382

84-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
83+
signIn(uiUser)
8584
val workspaceListPage = new WorkspaceListPage
8685
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName)
8786
workspaceMethodConfigPage.open
@@ -99,7 +98,6 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
9998

10099
"launch workflow on set without expression" in withWebDriver { implicit driver =>
101100
val wsName = "TestSpec_FireCloud_launch_workflow_on_set_without_expression" + UUID.randomUUID.toString
102-
implicit val authToken = Config.AuthTokens.testFireC
103101

104102
api.workspaces.create(billingProject, wsName)
105103
register cleanUp api.workspaces.delete(billingProject, wsName)
@@ -109,7 +107,7 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
109107
api.importMetaData(billingProject, wsName, "entities", TestData.HundredAndOneSampleSet.sampleSetCreation)
110108
api.importMetaData(billingProject, wsName, "entities", TestData.HundredAndOneSampleSet.sampleSetMembership)
111109

112-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
110+
signIn(uiUser)
113111
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName).open
114112
val methodConfigDetailsPage = workspaceMethodConfigPage.importMethodConfig(TestData.SimpleMethodConfig.namespace,
115113
TestData.SimpleMethodConfig.name, TestData.SimpleMethodConfig.snapshotId, methodConfigName, "sample")
@@ -125,12 +123,11 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
125123

126124
"launch workflow with input not defined" in withWebDriver { implicit driver =>
127125
val wsName = "TestSpec_FireCloud_launch_workflow_input_not_defined" + UUID.randomUUID.toString
128-
implicit val authToken = Config.AuthTokens.testFireC
129126
api.workspaces.create(billingProject, wsName)
130127
register cleanUp api.workspaces.delete(billingProject, wsName)
131128
api.importMetaData(billingProject, wsName, "entities", TestData.SingleParticipant.participantEntity)
132129

133-
signIn(Config.Accounts.testUserEmail, Config.Accounts.testUserPassword)
130+
signIn(uiUser)
134131
val workspaceMethodConfigPage = new WorkspaceMethodConfigPage(billingProject, wsName)
135132
workspaceMethodConfigPage.open
136133
val methodConfigDetailsPage = workspaceMethodConfigPage.importMethodConfig(TestData.SimpleMethodConfig.namespace,
@@ -154,4 +151,4 @@ class MethodConfigTabSpec extends FreeSpec with WebBrowserSpec with CleanUp {
154151
}
155152

156153

157-
}
154+
}

0 commit comments

Comments
 (0)