Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove WebUI e2e-tests dependency on det-deploy #575

Merged
merged 26 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
50920bd
make local copy of tools
hamidzr May 21, 2020
7594755
update tools to work on a different set of ports
hamidzr May 21, 2020
b5d64e9
change the directory name. affects docker compose project name
hamidzr May 21, 2020
68e96f4
e2e updates
hamidzr May 21, 2020
f7f7fa2
tools: ready check suggestion
hamidzr May 21, 2020
33cf89e
wip
hamidzr May 21, 2020
e9e6301
remove signs of docker
hamidzr May 21, 2020
3941e88
remove baseUrl from cypress.json
hamidzr May 22, 2020
24d611b
delegate test development to e2e-test scripts
hamidzr May 22, 2020
c99d9f2
separate pre-e2e_tests from cluster set up
hamidzr May 22, 2020
8924db3
use the "with" pattern for cluster setup and teardown
hamidzr May 22, 2020
fa11169
remove run_cluster_cmd top level method
hamidzr May 22, 2020
f23d1e0
fix a logger info message
hamidzr May 22, 2020
f4536a1
rename the port cli options and add host
hamidzr May 22, 2020
3c636bb
remove nonessential make targets
hamidzr May 22, 2020
50d09f0
remove signal handler. in favor of "try.. finally"
hamidzr May 22, 2020
0105379
update readme
hamidzr May 28, 2020
673cca6
feat: create experiments in parallel
hamidzr May 29, 2020
02e6e81
todo for cluster check
hamidzr May 29, 2020
065fee1
rename e2e-cluster to test-cluster
hamidzr May 29, 2020
6087ae9
remove "tools" todos
hamidzr May 29, 2020
ffda846
add a readme to test cluster and remove PROJECT_ROOT usage
hamidzr May 29, 2020
62a4aa7
remove yarn usage
hamidzr May 29, 2020
50f0f7c
bring ci cypress config
hamidzr May 29, 2020
3ef0a1b
add more help and description
hamidzr May 29, 2020
669c4cc
avoid using shell concurrency for more portability
hamidzr Jun 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ commands:
-w /webui/tests \
--env DET_MASTER=determined-master:8080 \
cypress/included:4.3.0 \
--config-file cypress-docker.json \
--config-file cypress-ci.json \
--config "defaultCommandTimeout=30000,baseUrl=http://determined-master:8080" \
--browser chrome \
--headless
Expand Down
33 changes: 11 additions & 22 deletions webui/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
.PHONY: get-deps clean e2e-tests docker-e2e-tests

export INTEGRATIONS_HOST_PORT ?= 5300

.PHONY: get-deps
get-deps:
for i in `seq 3`; do \
npm ci --no-audit && break ; \
done

.PHONY: clean-test-artifacts
clean-test-artifacts:
rm -rf cypress/screenshots/*
rm -rf cypress/videos/*

.PHONY: clean
clean: clean-test-artifacts
rm -rf node_modules/

test: docker-e2e-tests
.PHONY: test
test:
python ./bin/e2e-tests.py e2e-tests

.PHONY: check
check:
yarn run lint

.PHONY: fmt
fmt:
yarn run lint --fix

pre-e2e-tests:
python ./bin/e2e-tests.py pre-e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)

post-e2e-tests:
python ./bin/e2e-tests.py post-e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)

run-e2e-tests:
python ./bin/e2e-tests.py run-e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)

e2e-tests:
python ./bin/e2e-tests.py e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)

docker-run-e2e-tests:
python ./bin/e2e-tests.py docker-run-e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)

docker-e2e-tests:
python ./bin/e2e-tests.py docker-e2e-tests --integrations-host-port $(INTEGRATIONS_HOST_PORT)
.PHONY: dev-tests
dev-tests:
python ./bin/e2e-tests.py dev-tests
44 changes: 44 additions & 0 deletions webui/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# WebUI End-to-end Tests
hamidzr marked this conversation as resolved.
Show resolved Hide resolved

We use [Cypress](https://www.cypress.io/) to enable end-to-end testing of our
two SPAs, Elm and React, and in some sense the whole det cluster.

We provide a test script to take care of depdencies around Cypress commands.
Let's call this the "test script" for the rest of the this document.

## Requirements

When the tester loads up it loads the WebUI through a given master address
(`$HOST`) and port (`$PORT`)

Based the tester requirements and ease of test development the following
assumptions are made:

- It's a brand new cluster
- The cluster is isolated. Meaning this tester is the only entity interacting
with the cluster

Once the cluster is ready and accessible run the tests:

```
./bin/e2e-tests.py --det-port $PORT pre-e2e-tests && \
./bin/e2e-tests.py --det-port $PORT run-e2e-tests
```

Note that it's is important that one immediately follows the other since the
pre-e2e-tests target starts some experiments.

### Using the bundled cluster manager

For ease of use and quicker local testing we provide an option to set up and
tear down such a cluster through the test script.

Before the tests can be started we need to build the cluster including the WebUI
to make sure the served WebUI and cluster in general are up to date.

Issue the following command:
`./bin/e2e-tests.py e2e-tests` which in turn will:

1. Set up a test cluster
2. Run the Cyrpess tests `Cypress run`
3. Tear down the cluster and clean up in case of errors
36 changes: 22 additions & 14 deletions webui/tests/bin/createUserAndExperiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
USER_WITH_PASSWORD_PASSWORD = "special-pw"
USER_WITHOUT_PASSWORD_USERNAME = "user-wo-pw"

determined_root_dir = pathlib.Path(__file__).absolute().parents[3]
noop_dir = determined_root_dir.joinpath("e2e_tests", "tests", "fixtures", "no_op")
noop_config = "single-very-many-long-steps.yaml"


def wait_for_process(process):
# Avoid hang on macOS
Expand Down Expand Up @@ -43,6 +47,7 @@ def create_user(username, password=""):
wait_for_process(p)


print("setting up users..")
hkang1 marked this conversation as resolved.
Show resolved Hide resolved
# First login as admin to avoid having to authenticate downstream
login_as("admin")

Expand All @@ -55,18 +60,21 @@ def create_user(username, password=""):
# Login as non-default user with password
login_as(USER_WITH_PASSWORD_USERNAME, USER_WITH_PASSWORD_PASSWORD)


# Create experiments
determined_root_dir = pathlib.Path(__file__).absolute().parents[3]
experiment_dir = determined_root_dir.joinpath("e2e_tests", "tests", "fixtures", "no_op")

for _ in range(4):
subprocess.run(
[
"det",
"experiment",
"create",
str(experiment_dir.joinpath("single-very-many-long-steps.yaml")),
str(experiment_dir),
],
check=True,
)
def createExperiment(directory, config_file, count):
cmd = [
"det",
"experiment",
"create",
str(directory.joinpath(config_file)),
str(directory),
]

procs = [subprocess.Popen(cmd) for _ in range(count)]
for p in procs:
p.wait()


print("creating experiments..")
hamidzr marked this conversation as resolved.
Show resolved Hide resolved
createExperiment(noop_dir, noop_config, 4)
Loading