Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sm/test/uxi-9657-test…
Browse files Browse the repository at this point in the history
…-refactor
  • Loading branch information
SiasMey committed Dec 6, 2024
2 parents 94a3c31 + 1e91925 commit ba24599
Show file tree
Hide file tree
Showing 112 changed files with 442 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5.1.0
with:
go-version: "${{ env.go_version }}"

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,26 @@ permissions:
contents: write

jobs:
acceptance-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Inject Env File
run: echo "${{ secrets.ACCEPTANCE_ENV_FILE }}" > acceptance.env

- name: Run Acceptance Tests
run: just acceptance-tests acceptance.env

goreleaser:
runs-on: Signer
needs: acceptance-tests
steps:
- uses: actions/[email protected]
with:
Expand All @@ -37,6 +55,7 @@ jobs:
with:
go-version-file: 'go.mod'
cache: true

- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ terraform.tfstate*
# python
**/*.pyc
.DS_Store

*.env
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The following example uses Zsh (default) on macOS (Apple Silicon).

```console
RELEASE=x.y.z
wget -q https://github.com/aruba-uxi/terraform-provider-hpeuxi/releases/download/v${RELEASE}/terraform-provider-hpeuxi_${RELEASE}_darwin_arm64.zip
wget https://github.com/aruba-uxi/terraform-provider-hpeuxi/releases/download/v${RELEASE}/terraform-provider-hpeuxi_${RELEASE}_darwin_arm64.zip
```

3. Extract the plugin.
Expand Down
31 changes: 19 additions & 12 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ lint:

python -m tools.lint-attribution lint

terraform fmt -recursive -check

fmt:
python -m tools.lint-attribution format
go run github.com/segmentio/golines@v0.12.2 -w .
go run golang.org/x/tools/cmd/goimports@latest -local github.com/aruba-uxi -w .
go run mvdan.cc/gofumpt@latest -w .
terraform fmt --recursive .

tidy-provider:
go mod tidy
Expand All @@ -99,22 +102,26 @@ coverage-provider:
tidy-tools:
cd {{ TOOLS_PROVIDER_DIR }} && go mod tidy

acceptance-tests +ARGS='':
acceptance-tests ENV_PATH='' +ARGS='':
#!/usr/bin/env bash
read -p "This is going to run requests against UXI backend. Continue (y/Y)? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# we run these seperately so that they do not interfere with each other since GoLang executes
# tests in different directories at the same time
for dir in "datasources" "resources"
do
echo "Running tests in $dir..."
TF_ACC=1 go test -v ./test/live/$dir/... -race {{ ARGS }}
done
if [ -z "{{ ENV_PATH }}" ]; then
echo "Error: ENV_PATH argument is required" >&2
exit 1
fi

if [ ! -f "{{ ENV_PATH }}" ]; then
echo "Error: File specified ("{{ ENV_PATH }}") does not exist" >&2
exit 1
fi

# we run these separately so that they do not interfere with each other since GoLang executes
# tests in different directories at the same time
for dir in "datasources" "resources"
do
echo "Running tests in $dir..."
env $(cat {{ ENV_PATH }} | xargs) TF_ACC=1 go test -v ./test/live/$dir/... -race {{ ARGS }}
done

test +ARGS='':
just test-client {{ ARGS }}
Expand Down
44 changes: 34 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,46 @@ just generate-config-api-client

## Running Acceptance Tests

Set the `GREENLAKE_UXI_CLIENT_ID` and `GREENLAKE_UXI_CLIENT_SECRET` environment variables for the acceptance test customer. The client credentials must have sufficient permissions execute create, read, update and destroy operations for the UXI customer. Also set the `UXI_HOST` environment variable to target the staging
environment.
Create a file called `acceptance.env` containing the following environment variables. See the table below for a description of the fields.

```bash
export HPEUXI_CLIENT_ID=<client_id>
export HPEUXI_CLIENT_SECRET=<client_secret>
export HPEUXI_HOST_OVERRIDE=api.staging.capedev.io
```
ACCEPTANCE_AGENT_ID=<acceptance_agent_id>
ACCEPTANCE_AGENT_PROVISION_HOST=<acceptance_agent_provision_host>
ACCEPTANCE_AGENT_PROVISION_SERIAL=<acceptance_agent_provision_serial>
ACCEPTANCE_CUSTOMER_ID=<acceptance_customer_id>
ACCEPTANCE_GROUP_ID_ROOT=<acceptance_group_id_root>
ACCEPTANCE_SENSOR_ID=<acceptance_sensor_id>
ACCEPTANCE_SERVICE_TEST_ID=<acceptance_service_test_id>
ACCEPTANCE_WIRED_NETWORK_ID=<acceptance_wired_network_id>
ACCEPTANCE_WIRELESS_NETWORK_ID=<acceptance_wireless_network_id>
HPEUXI_CLIENT_ID=<hpeuxi_client_id>
HPEUXI_CLIENT_SECRET=<hpeuxi_client_secret>
HPEUXI_HOST_OVERRIDE=<hpeuxi_host_override>
HPEUXI_PROVISION_TOKEN=<hpeuxi_provision_token>
```

| Environment Variable | Description |
|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| ACCEPTANCE_AGENT_ID | ID of an agent on customer. |
| ACCEPTANCE_AGENT_PROVISION_SERIAL | Serial number of an agent to be provisioned. Keep this constant between test runs to avoid excessive provisioning of agents. |
| ACCEPTANCE_CUSTOMER_ID | ID of the customer against which the acceptance tests will be run. |
| ACCEPTANCE_GROUP_ID_ROOT | ID of the root group. |
| ACCEPTANCE_SENSOR_ID | ID of a hardware sensor on the customer. |
| ACCEPTANCE_SERVICE_TEST_ID | ID of a service test on the customer. |
| ACCEPTANCE_WIRED_NETWORK_ID | ID of a wired network on the customer. |
| ACCEPTANCE_WIRELESS_NETWORK_ID | ID of a wireless network on the customer. |
| DEVICE_GATEWAY_HOST | Host address of the device gateway (against which the agent provisioning will be run) |
| HPEUXI_CLIENT_ID | CLIENT_ID component of the UXI API credentials as obtained from Greenlake. |
| HPEUXI_CLIENT_SECRET | CLIENT_SECRET component of the UXI API credentials as obtained from Greenlake. |
| HPEUXI_HOST_OVERRIDE | Host address of the configuration API (against which the configuration API requests will be run). |
| HPEUXI_PROVISION_TOKEN | Token used to provision agents for the given customer. |

Then run the following command to execute the acceptance tests against the given customer.

```shell
just acceptance-tests
just acceptance-tests acceptance.env
```

Note: it is possible to run acceptance tests against any UXI customer, if the configurations in
`test/live/config/config.go` are updated to values for the given customer.

## Building and Distribution

All builds must be signed by HPE before distribution.
Expand Down
7 changes: 5 additions & 2 deletions docs/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/resources/agent.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions docs/resources/agent_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions docs/resources/group.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions docs/resources/network_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions docs/resources/sensor_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/resources/service_test.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions docs/resources/service_test_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/resources/wired_network.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ba24599

Please sign in to comment.