You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Warning: Never run this tests on production project with real data, always create project for testing purposes!!!**
85
-
86
-
*Note: For automated tests, the tests are run again three times by default if they fail. For local development this would be quite annoying,
87
-
so you can disable this by creating new file `phpunit-retry.xml` from `phpunit-retry.xml.dist`*
88
-
89
-
The main purpose of these tests is "black box" test driven development of Keboola Connection. These tests guards the API implementation.
90
-
91
-
Tests should be executed against local dockerized version of [Keboola Connection](https://github.com/keboola/connection/) (private repo).
92
-
These tests and local KBC are configured to share docker network where the Storage API and Manage API endpoints are provided.
93
-
These APIs are available at `http://connection-apache/` endpoint from clients tests.
94
-
95
-
96
-
Before executing tests please install dev dependencies:
97
-
-`docker compose build`
98
-
-`docker compose run --rm dev composer install`
99
-
100
-
Tests are divided into multiple test suites.
101
-
102
-
### Common test suite
103
-
This test suite expects following environment variables set:
104
-
-`STORAGE_API_URL` - URL of Keboola Storage API (https://connection.keboola.com/)
105
-
-`STORAGE_API_TOKEN` - Storage API token associated to user (Admin master token) with all permissions. There are no special requirements for project storage backend.
106
-
-`STORAGE_API_GUEST_TOKEN` - Storage API token associated to user (Admin master token) with guest role in same project as `STORAGE_API_TOKEN`.
107
-
-`STORAGE_API_READ_ONLY_TOKEN` - Storage API token associated to user (Admin master token) with readOnly role in same project as `STORAGE_API_TOKEN`.
108
-
-`STORAGE_API_SHARE_TOKEN` - Storage API token associated to user (Admin master token) with share role in same project as `STORAGE_API_TOKEN`.
109
-
-`STORAGE_API_MAINTENANCE_URL` - URL for maintenance testing (https://maintenance-testing.keboola.com/)
110
-
111
-
112
-
You can export variables manually, or you can create and fill file `set-env.sh` as copy of attached `set-env.template.sh`.
113
-
114
-
Then you can run tests:
115
-
116
-
`source ./set-env.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite common`
117
-
118
-
119
-
### Redshift backend test suite
120
-
121
-
This test suite expects following environment variables set:
122
-
-`STORAGE_API_URL` - URL of Keboola Storage API (https://connection.keboola.com/)
123
-
-`STORAGE_API_TOKEN` - Storage API token associated to user (Admin master token) with all permissions. **Project must have `Redshift` set as default backend.**
124
-
-`REDSHIFT_NODE_COUNT` - (optional) Set Redshift node count `default=1`
125
-
126
-
You can export variables manually, or you can create and fill file `set-env.redshift.sh`
127
-
as copy of attached `set-env.redshift.template.sh`.
128
-
129
-
Then you can run tests:
130
-
131
-
`source ./set-env.redshift.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite backend-redshift-part-1`
132
-
`source ./set-env.redshift.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite backend-redshift-part-2`
133
-
134
-
### Snowflake backend test suite
135
-
This test suite expects following environment variables set:
136
-
-`STORAGE_API_URL` - URL of Keboola Storage API (https://connection.keboola.com/)
137
-
-`STORAGE_API_TOKEN` - Storage API token associated to user (Admin master token) with all permissions. **Project must have `snowflake` set as default backend.**
138
-
139
-
140
-
You can run these tests in docker:
141
-
142
-
`source ./set-env.snowflake.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite backend-snowflake-part-1`
143
-
`source ./set-env.snowflake.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite backend-snowflake-part-2`
144
-
145
-
### Mixed backend test suite
146
-
Project can support multiple backends, this is useful for migrations from one backend to another.
147
-
These tests require project with all backend assigned (redshift, snowflake).
148
-
149
-
This test suite expects following environment variables set:
150
-
-`STORAGE_API_URL` - URL of Keboola Storage API (https://connection.keboola.com/)
151
-
-`STORAGE_API_TOKEN` and `STORAGE_API_LINKING_TOKEN` - Storage API token associated to user (Admin master token) with all permissions. Project must have assigned `snowflake` and `redshift` backend. STORAGE_API_TOKEN and STORAGE_API_LINKING_TOKEN have to be tokens to different project in same organization.
152
-
-`STORAGE_API_GUEST_TOKEN` - Storage API token associated to user (Admin master token) with guest role in same project as `STORAGE_API_TOKEN`.
153
-
-`STORAGE_API_SHARE_TOKEN` - Storage API token associated to user (Admin master token) with share role in same project as `STORAGE_API_TOKEN`.
154
-
-`STORAGE_API_MAINTENANCE_URL` - URL for maintenance testing (https://maintenance-testing.keboola.com/)
155
-
-`STORAGE_API_TOKEN_ADMIN_2_IN_SAME_ORGANIZATION` - Storage API token associated to project in the same organization as `STORAGE_API_TOKEN` but with different admin as `STORAGE_API_TOKEN`.
156
-
-`STORAGE_API_TOKEN_ADMIN_3_IN_OTHER_ORGANIZATION` - Storage API token associated to other admin as `STORAGE_API_TOKEN` and project in the other organization as `STORAGE_API_TOKEN`.
157
-
You can export variables manually or you can create and fill file `set-env.mixed.sh` as copy of attached `set-env.mixed.template.sh`.
158
-
159
-
Then you can run tests:
160
-
161
-
`source ./set-env.mixed.sh && docker compose run --rm dev vendor/bin/phpunit --testsuite backend-mixed'`
162
-
163
-
## Running test from PHPStorm
164
-
165
-
The whole test suite is quite big and it can take few hours. So it is a good idea to run just a testcase which you are interested in from PHPStorm, or you can run them from a console (using `--filter` option).
166
-
167
-
**How to set up PHPStorm for running tests:**
168
-
- go to Settings / Languages & Frameworks / PHP
169
-
- row CLI -> three dots
170
-
- Plus button -> `From Docker, Vagrant, VM, WSL, Remote...`
171
-
- Select `Docker Compose`; Service `dev-xdebug`; Environment variables define value from your `set-env.php`
172
-
- an easy way how to do it is copy content of `set-env.php` without `export ` prefix -> click on the icon in Env. vars. -> click on the paste icon. It should pass all the key=value entries in the window. If it doesn't work, set them manually.
173
-
- Set Path mappings to `<Project root> -> /code` (`<Project root>` is an absolute path to the project directory)
174
-
- hint: create different interpreters for different environments
175
-
176
-
_Note: see [this link](https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html) for more information and screenshots about the description above._
0 commit comments