Skip to content

Commit 629ec09

Browse files
authored
Merge pull request #6270 from keboola/zajca/sapi-clean
CT-2247, CT-2248 cleanup sapi files, allow monorepo split
2 parents 22d2e18 + 4005105 commit 629ec09

14 files changed

Lines changed: 3 additions & 228 deletions

.gitignore

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,9 @@ config.php
55
composer.lock
66
composer.phar
77
vendor
8-
set-env.sh
9-
set-env.redshift.sh
10-
set-env.snowflake.sh
11-
set-env.mysql.sh
12-
set-env.mixed.sh
13-
set-env.sharing.sh
148
*.kdev4
159
.kdev4
1610
.env
17-
snowflake_linux_x8664_odbc.tgz
1811
REVISION
1912
/cache
20-
phpunit-retry.xml
2113
.phpunit.result.cache
22-
set-env.global-search-mixed.sh
23-
set-env.global-search-sox.sh
24-
set-env.global-search.sh
25-
set-env.global-search-bq.sh

README.md

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -79,102 +79,6 @@ $exporter->exportTable('in.c-main.my-table', './in.c-main.my-table.csv', []);
7979

8080
```
8181

82-
## Tests
83-
84-
**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._
177-
17882
## License
17983

18084
See [LICENSE](./LICENSE) file.

docker-compose.yml

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,14 @@
11
services:
2-
tests: &base
2+
dev: &dev
33
build:
44
context: .
5-
image: keboola/storage-api-tests
6-
environment:
7-
- STORAGE_API_URL
8-
- STORAGE_API_TOKEN
9-
- STORAGE_API_LINKING_TOKEN
10-
- STORAGE_API_GUEST_TOKEN
11-
- STORAGE_API_READ_ONLY_TOKEN
12-
- STORAGE_API_SHARE_TOKEN
13-
- STORAGE_API_DEFAULT_BRANCH_TOKEN
14-
- STORAGE_API_REVIEWER_TOKEN
15-
- STORAGE_API_SECOND_REVIEWER_TOKEN
16-
- STORAGE_API_DEVELOPER_TOKEN
17-
- STORAGE_API_MAINTENANCE_URL
18-
- STORAGE_API_TOKEN_ADMIN_2_IN_SAME_ORGANIZATION
19-
- STORAGE_API_TOKEN_ADMIN_3_IN_OTHER_ORGANIZATION
20-
- MANAGE_API_TOKEN_ADMIN
21-
- MANAGE_API_TOKEN_WITHOUT_SCOPE
22-
- MANAGE_API_TOKEN_WITH_CREATE_PROTECTED_DEFAULT_BRANCH_TOKEN
23-
- REDSHIFT_HOSTNAME
24-
- REDSHIFT_USER
25-
- REDSHIFT_PASSWORD
26-
- REDSHIFT_NODE_COUNT
27-
- SUITE_NAME
28-
- TRAVIS_BUILD_ID
29-
- BQ_KEY_FILE_FOR_EXTERNAL_BUCKET
30-
- BQ_DESTINATION_PROJECT_SERVICE_ACC_EMAIL
31-
- BQ_EXTERNAL_TABLE_GCS_BUCKET
32-
- BQ_EXTERNAL_BUCKET_REGION
33-
- SNOWFLAKE_HOST
34-
- SNOWFLAKE_USER
35-
- SNOWFLAKE_PASSWORD
36-
- SNOWFLAKE_DB_PREFIX
37-
- SNOWFLAKE_INBOUND_DATABASE_NAME
38-
- SNOWFLAKE_PRODUCER_HOST
39-
- SNOWFLAKE_PRODUCER_USER
40-
- SNOWFLAKE_PRODUCER_PASSWORD
41-
- SNOWFLAKE_PRODUCER_WAREHOUSE
42-
- SNOWFLAKE_PRODUCER_SHARED_DATABASE
43-
- SNOWFLAKE_PRODUCER_SHARE_NAME
44-
dev: &dev
45-
<<: *base
5+
image: keboola/storage-api-client
466
volumes:
477
- ./:/code
48-
- tools-cache:/tmp/tools-cache
498

509
dev-xdebug:
5110
<<: *dev
5211
build:
5312
context: docker/xdebug
54-
image: keboola/storage-api-tests-xdebug
13+
image: keboola/storage-api-client-xdebug
5514
command: tail -f /dev/null
56-
57-
networks:
58-
default:
59-
name: connection_api-tests
60-
external: true
61-
62-
volumes:
63-
tools-cache:

set-env.exasol.template.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

set-env.global-search-bq.template.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

set-env.global-search-mixed.template.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

set-env.global-search-sox.template.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

set-env.global-search.template.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

set-env.mixed.template.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

set-env.redshift.template.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)