Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 2 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,8 @@ requiring a manual refresh.

## Testing

The cvprac module provides system tests. To run the system tests, you
will need to update the `cvp_nodes.yaml` file found in test/fixtures.

Requirements for running the system tests:

- Need one CVP node for test with a test user account. Create the same
account on the switch used for testing. The user account information
follows:

username: CvpRacTest
password: AristaInnovates

If switch does not have correct username and/or password then the tests that
execute tasks will fail with the following error:

AssertionError: Execution for task id 220 failed and in the test log is the error:

Failure response received from the netElement : ' Unauthorized User '

- Test has dedicated access to the CVP node.
- CVP node contains at least one device in a container.
- Container or device has at least one configlet applied.
The cvprac module provides both unit tests and system tests.
To run the system tests, read the [detailed system test documentation](test/system/SYSTEM_TEST_CVP_SETUP.md) for more information on how to set up the environment.

To run the system tests:

Expand Down
53 changes: 53 additions & 0 deletions test/system/SYSTEM_TEST_CVP_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CVP System Test Setup

Prepare a dedicated CloudVision/CVP instance before running `test/system`.
The tests create, edit, execute, cancel, and delete CVP objects, so do not run
them against a shared or production CVP.

## CVP Requirements

- Create a CVP user with `network-admin` permissions.
- Create the same username and password on the test switch. Task execution
tests fail with `Unauthorized User` if the switch credentials do not match
the CVP login. **_Note: on Arista Cloud Test, these two steps are already done during lab deployment._**
- Add at least one test device to CVP inventory.
- Move the test device into the `Tenant` container, not `Undefined`.
- Apply at least one normal configlet directly to the test device. Use a
configlet assigned only to that device when possible, because tests edit
configlet contents to create tasks.
- Make sure there is no existing `RECONCILE_<device-name>` configlet for the
test device.
- Make sure the test device has an `Ethernet1` interface. Tag resource tests
assign and remove tags on `Ethernet1`.
- If you want image tests to exercise apply/remove image bundle paths, create
at least one image bundle. Otherwise those paths are skipped.

## Fixture

Update `test/fixtures/cvp_nodes.yaml` before running system tests.
- Change the username and password to the user with `network-admin` permissions that
was created during CVP configuration.
- Change `device` to the device hostname that was added to the **Tenant** Container.

```yaml
- node: cvp-hostname-or-ip
username: CvpRacTest
password: AristaInnovates
device: test-device-hostname
# api_token: optional-valid-token
# api_token_expired: optional-expired-token
# is_cvaas: false
# connect_timeout: 10
# request_timeout: 30
```

Multiple entries may be listed, but most system tests use the first entry.
Token tests are skipped unless `api_token` or `api_token_expired` is provided.

## Run

Run the full suite of tests.

```bash
make tests
```
11 changes: 9 additions & 2 deletions test/system/test_cvp_client_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@

''' System test for the CvpApi class

Refer to test/system/SYSTEM_TEST_CVP_SETUP.md for more details.

The file test/fixtures/cvp_nodes.yaml should be modified to
point to the CVP instance under test, with the associated username & password
and device name.

Requirements for CVP Node:
1) Test has dedicated access to the CVP node.
2) Contains at least one device in a container.
3) Container or device has at least one configlet applied.
2) Contains at least one device in the "Tenant" container.
3) Device has at least one configlet applied directly, without Reconcile configlets.
4) Device has a user account and password that matches the CVP username
and password. If device does not have correct username and/or password
then the tests that execute tasks will fail with the following error:
Expand All @@ -48,6 +54,7 @@
and in the test log is the error:

Failure response received from the netElement : ' Unauthorized User '
5) Device needs to have at least 1 interface called Ethernet1
'''
import os
import shutil
Expand Down
Loading