diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a812bea2f..84af6e635 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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: @@ -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 diff --git a/.travis.yml b/.travis.yml index e9e2db22a..705f0fb87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/acceptance/README.md b/acceptance/README.md index 7e67196eb..65e4e69bd 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -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 @@ -10,33 +10,10 @@ 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 @@ -44,15 +21,12 @@ to set them manually. |---|---| |`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 @@ -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: @@ -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 } @@ -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. diff --git a/script/acceptancetest b/script/acceptancetest index 5ed5b6d2f..3e24e77ab 100755 --- a/script/acceptancetest +++ b/script/acceptancetest @@ -2,4 +2,4 @@ # # Run the acceptance tests. -exec go test -p=1 github.com/huaweicloud/golangsdk/acceptance/... $@ +exec go test ./acceptance/openstack/... $@ diff --git a/script/test b/script/test deleted file mode 100755 index 1e03dff8a..000000000 --- a/script/test +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# -# Run all the tests. - -exec go test -tags 'acceptance fixtures' ./... $@