Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
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
17 changes: 5 additions & 12 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ As a contributor you will need to setup your workspace in a slightly different
way than just downloading it. Here are the basic instructions:

1. Configure your `$GOPATH` and run `go get` as described in the main
[README](/README.md#how-to-install) but add `-tags "fixtures acceptance"` to
get dependencies for unit and acceptance tests.
[README](/README.md#how-to-install).

```bash
go get -tags "fixtures acceptance" github.com/huaweicloud/golangsdk
go get github.com/huaweicloud/golangsdk
```

2. Move into the directory that houses your local repository:
Expand Down Expand Up @@ -222,25 +221,19 @@ environments in our [acceptance tests readme](/acceptance).
To run all tests:

```bash
go test -tags fixtures ./...
go test ./acceptance/...
```

To run all tests with verbose output:

```bash
go test -v -tags fixtures ./...
```

To run tests that match certain [build tags]():

```bash
go test -tags "fixtures foo bar" ./...
go test -v ./acceptance/...
```

To run tests for a particular sub-package:

```bash
cd ./path/to/package && go test -tags fixtures ./...
cd ./acceptance/openstack/sub-package && go test ./...
```

## Style guide
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: go
sudo: false
install:
- go get golang.org/x/crypto/ssh
- go get -v -tags 'fixtures acceptance' ./...
- go get -v ./...
- go get github.com/wadey/gocovmerge
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/goimports
Expand Down
66 changes: 13 additions & 53 deletions acceptance/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gophercloud Acceptance tests
# Golangsdk Acceptance tests

The purpose of these acceptance tests is to validate that SDK features meet
the requirements of a contract - to consumers, other parts of the library, and
Expand All @@ -10,49 +10,23 @@ to a remote API.
> be certain cases where this does not happen; always double-check to make sure
> you have no stragglers left behind.

### Step 1. Creating a Testing Environment
### Step 1. Set environment variables

Running tests on an existing OpenStack cloud can be risky. Malformed tests,
especially ones which require Admin privileges, can cause damage to the
environment. Additionally, you may incur bandwidth and service charges for
the resources used, as mentioned in the note above.

Therefore, it is usually best to first practice running acceptance tests in
an isolated test environment. Two options to easily create a testing
environment are [DevStack](https://docs.openstack.org/devstack/latest/)
and [PackStack](https://www.rdoproject.org/install/packstack/).

The following blog posts detail how to create reusable PackStack environments.
These posts were written with Gophercloud in mind:

* http://terrarum.net/blog/building-openstack-environments.html
* http://terrarum.net/blog/building-openstack-environments-2.html
* http://terrarum.net/blog/building-openstack-environments-3.html

### Step 2. Set environment variables

A lot of tests rely on environment variables for configuration - so you will need
to set them before running the suite. If you're testing against pure OpenStack APIs,
you can download a file that contains all of these variables for you: just visit
the `project/access_and_security` page in your control panel and click the "Download
OpenStack RC File" button at the top right. For all other providers, you will need
to set them manually.
Tests rely on environment variables for configuration, so you will need
to set them manually before running the suite.

#### Authentication

|Name|Description|
|---|---|
|`OS_USERNAME`|Your API username|
|`OS_PASSWORD`|Your API password|
|`OS_AUTH_URL`|The identity URL you need to authenticate|
|`OS_TENANT_NAME`|Your API tenant name|
|`OS_TENANT_ID`|Your API tenant ID|

#### General

|Name|Description|
|---|---|
|`OS_DOMAIN_NAME`|Your API account name|
|`OS_DOMAIN_ID`|Your API account ID|
|`OS_TENANT_NAME`|Your API project name|
|`OS_TENANT_ID`|Your API project ID|
|`OS_REGION_NAME`|The region you want your resources to reside in|
|`OS_AUTH_URL`|The identity URL you need to authenticate|

#### Compute

Expand All @@ -65,19 +39,12 @@ to set them manually.
|`OS_NETWORK_NAME`|The internal/private network to launch instances on|
|`OS_EXTGW_ID`|The external/public network|

#### Database

|Name|Description|
|---|---|
|`OS_DB_DATASTORE_TYPE`|The Datastore type to use. Example: `mariadb`|
|`OS_DB_DATASTORE_VERSION`|The Datastore version to use. Example: `mariadb-10`|

#### Shared file systems
|Name|Description|
|---|---|
|`OS_SHARE_NETWORK_ID`| The share network ID to use when creating shares|

### 3. Run the test suite
### 2. Run the test suite

From the root directory, run:

Expand All @@ -91,7 +58,7 @@ Alternatively, add the following to your `.bashrc`:
golangsdktest() {
if [[ -n $1 ]] && [[ -n $2 ]]; then
pushd $GOPATH/src/github.com/huaweicloud/golangsdk
go test -v -tags "fixtures acceptance" -run "$1" github.com/huaweicloud/golangsdk/acceptance/openstack/$2 | tee ~/golangsdk.log
go test -v github.com/huaweicloud/golangsdk/acceptance/openstack/$1 -run "$2" | tee ~/golangsdk.log
popd
fi
}
Expand All @@ -100,14 +67,7 @@ fi
Then run either groups or individual tests by doing:

```shell
$ golangsdktest TestFlavorsList compute/v2
$ golangsdktest TestFlavors compute/v2
$ golangsdktest Test compute/v2
$ golangsdktest networking/v1 TestVpcList
$ golangsdktest networking/v1 TestVpcsCRUD
```

### 4. Notes

#### Compute Tests

* In order to run the `TestBootFromVolumeMultiEphemeral` test, a flavor with ephemeral disk space must be used.
* The `TestDefSecRules` tests require a compatible network driver and admin privileges.
2 changes: 1 addition & 1 deletion script/acceptancetest
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# Run the acceptance tests.

exec go test -p=1 github.com/huaweicloud/golangsdk/acceptance/... $@
exec go test ./acceptance/openstack/... $@
5 changes: 0 additions & 5 deletions script/test

This file was deleted.