Skip to content

Commit 435591f

Browse files
committed
update integration tests to use docker
1 parent 9fd5bff commit 435591f

File tree

3 files changed

+150
-30
lines changed

3 files changed

+150
-30
lines changed

examples/integration_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def verify_avro_https():
386386
'error_cb': error_cb,
387387
'api.version.request': api_version_request}
388388

389-
conf.update(testconf.get('schema_registry_https', {}))
389+
conf.update(testconf.get('avro-https'))
390390

391391
p = avro.AvroProducer(conf)
392392

@@ -429,7 +429,7 @@ def verify_avro_https():
429429
'auto.offset.reset': 'earliest'
430430
}}
431431

432-
conf.update(testconf.get('schema_registry_https', {}))
432+
conf.update(testconf.get('avro-https'))
433433

434434
c = avro.AvroConsumer(conf)
435435
c.subscribe([(t['topic']) for t in combinations])

tests/README.md

Lines changed: 138 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
# Conventions Used in This Document
2+
Unless otherwise noted all commands, file and directory references are relative to the *source root* directory.
3+
4+
## Terminology
5+
- modes: Collection of integration tests to be run; a mode(singular) represents an individual integration testing unit
6+
- testconf: [JSON](https://tools.ietf.org/html/rfc8259) formatted configuration file.
7+
Example: [tests/testconf-example.json](./tests/testconf-example.json) for formatting.
8+
19
Unit tests
210
==========
3-
411
From top-level directory run:
512

613
$ tox
@@ -10,24 +17,47 @@ From top-level directory run:
1017
Integration tests
1118
=================
1219

13-
**NOTE**: Integration tests require an existing Kafka cluster and a `testconf.json` configuration file. Any value provided
14-
in `testconf.json` prefixed with '$' will be treated as an environment variable and automatically resolved.
20+
## Introduction
21+
Integration tests, `tests` henceforth, are broken up into two distinct categories.
22+
1. Default
23+
2. Ancillary
24+
25+
Default modes can be executed against any unsecured cluster with a minimally configured [testconf](#configuration).
26+
27+
Default Modes: consumer, producer, avro, performance, admin
28+
29+
Ancillary modes require additional steps to be taken prior to `mode` execution. Per `mode` instructions are covered in
30+
within sections sharing the same name.
31+
32+
Ancillary Modes: [throttle](#throttle), [avro-https](#avro-https), [avro-basic-auth](#avro-basic-auth)
33+
34+
## Prerequisites
35+
All test modes require access to a running Kafka cluster configured with at least one PLAINTEXT listener.
36+
37+
Test modes prefixed with `avro` require a running [Confluent Schema Registry](https://docs.confluent.io/current/schema-registry/docs/index.html)
1538

16-
At a minimum you must specify `bootstrap.servers` and `topic` within `testconf.json`. Please reference [tests/testconf-example.json](tests/testconf-example.json) for formatting.
39+
**Note** Test mode `avro` is included in the default modes list.
1740

41+
In order to keep things contained resources have been provided to deploy a dockerized cluster which developers are encouraged to leverage.
42+
See the [Docker](#docker) section below for additional requirements and details.
43+
44+
All tests require some degree of configuration to run.
45+
See [#Configuration](#configuration) for instructions on configuring tests.
46+
47+
## Running tests
1848
**WARNING**: These tests will create new topics and consumer groups.
1949

20-
To run all of the integration test `modes` uncomment the following line from `tox.ini` and provide the location to your `testconf.json`
50+
To run all of the default test `modes` uncomment the following line from `tox.ini` and provide the location to your `testconf`
2151

22-
#python examples/integration_test.py --conf <testconf.json>
52+
#python examples/integration_test.py --conf testconf.json
2353

24-
You can also run the integration tests outside of `tox` by running this command from the source root directory
54+
You can also run the integration tests outside of `tox` with the command below.
2555

26-
python examples/integration_test.py --conf <testconf.json>
56+
python examples/integration_test.py --conf testconf.json
2757

28-
To run individual integration test `modes` use the following syntax
58+
To specify which `mode` or `modes` to run use the following syntax
2959

30-
python examples/integration_test.py --<test mode> --conf <testconf.json>
60+
python examples/integration_test.py --<test mode 1> --<test mode n...> --conf <testconf>
3161

3262
For example:
3363

@@ -37,10 +67,62 @@ To get a list of modes you can run the integration test manually with the `--hel
3767

3868
python examples/integration_tests.py --help
3969

70+
## Configuration
71+
Tests are configured with a JSON encoded file referred to as a `testconf` to be provided as an argument upon test execution.
72+
73+
Test `mode` configuration can be broken up into 3 main categories.
74+
1. Global, minimal client configuration values required by every test mode.
75+
1. bootstrap.servers
76+
2. topic
77+
2. Default, client configurations required to execute schema registry tests.
78+
1. schema.registry.url
79+
3. Ancillary, client configurations required to execute a specific test mode. These are covered in their own sections
80+
* See the [Ancillary](#ancillary-modes) section for configuration requirements
81+
82+
The following basic conventions should be followed when constructing the `testconf` file.
83+
- Global configuration values should be defined as members of the root json object.
84+
- Default configuration values should also be defined as members of the root object.
85+
- Ancillary mode configuration values should be defined as object members named the same as the mode.
86+
87+
Values can be defined literally or prefixed with '$'.
88+
Values prefixed with '$' represent environment variables which will be resolved at runtime.
89+
90+
See [../tests/testconf-example.json](../tests/testconf-example.json) for an example.
91+
92+
## Docker
93+
94+
A complete docker cluster setup is included within the directory `./docker`.
95+
This is the preferred method for executing integration tests but standalone cluster will do as well.
96+
97+
#### Prerequisites:
98+
99+
1. docker-compose 3.0 +
100+
2. docker-engine 1.13.0+
101+
102+
To set up a cluster with the default settings execute the following commands:
103+
```bash
104+
source ./docker/.env
105+
# If running HTTPS enabled tests
106+
./docker/bin/certify
107+
docker-compose -f ./docker/docker-compose.yaml up -d
108+
```
109+
110+
Use the `testconf` provided in the ./docker/conf directory for all tests.
111+
Unless noted elsewhere the default configuration should suffice.
112+
113+
When tests have completed you can destroy the cluster by executing the command
114+
```bash
115+
docker-compose -f ./docker/docker-compose.yaml down -v --remove-orphans
116+
```
117+
118+
## Ancillary Modes
119+
120+
### Throttle
121+
122+
The throttle_cb integration test requires aggressive throttling to be configured to simulate heavy load.
123+
124+
No cluster or testconf changes are required however the following preliminary steps must be executed prior to test execution.
40125

41-
Throttle Callback test
42-
======================
43-
The throttle_cb integration test requires an additional step and as such is not included in the default test modes.
44126
In order to execute the throttle_cb test you must first set a throttle for the client 'throttled_client' with the command below:
45127

46128
kafka-configs --zookeeper <zookeeper host>:<zookeeper port> \
@@ -59,16 +141,51 @@ To remove the throttle you can execute the following
59141
--entity-name throttled_client --entity-type clients
60142

61143

62-
HTTPS Schema Registry test
63-
==========================
144+
### Avro Https
145+
146+
#### Cluster Requirements
147+
1. Schema Registry must be configured with a HTTPS listener and optionally TLS mutual auth.
148+
149+
For instructions on how to configure the Schema Registry please see the [Confluent Schema Registry documentation](https://docs.confluent.io/current/schema-registry/docs/security.html#configuring-the-rest-api-for-http-or-https)
150+
151+
**Docker:** Prior to starting the cluster you must first generate the certificates by running the following.
152+
153+
./docker/bin/certify
154+
155+
#### Testconf Requirements
156+
1. Add `avro-https` to the root object with the following members
157+
1. `schema.registry.url`; for the HTTPS listener
158+
2. `schema.registry.ssl.ca.location`; location of the CA certificate used to verify the Schema Registry certificate,
159+
2. **Optional:** configuring tls client auth:
160+
1. `schema.registry.ssl.certificate.location`; client certificate location
161+
2. `schema.registry.ssl.key.location`; client private key location
162+
163+
#### Execute test
164+
python examples/integration_test.py --avro-https --conf testconf.json
165+
166+
### Avro Basic Auth
167+
168+
#### Cluster Requirements
169+
1. A running Schema Registry configured with http basic authentication enabled.
170+
171+
**Docker:** REST_AUTHENTICATION_METHOD=BASIC docker-compose -f ./docker/docker-compose.yaml up -d
172+
173+
#### Testconf Requirements
174+
1. schema.registry.url must include user information in the url
175+
* `"schema.registry.url" : "http://ckp_tester:test_secret@schema_registry:8081"`
64176

65-
HTTPS tests require access to a Schema Registry instance configured to with at least one HTTPS listener.
177+
2. add `avro-basic-auth` to the root object with the following members
178+
1. `schema.registry.basic.auth.user.info`
179+
2. `sasl.username`
180+
3. `sasl.password`
66181

67-
For instructions on how to configure the Schema Registry please see the Confluent documentation:
182+
Configuration details can be found at the following links:
183+
1. [schema.registry.*](https://docs.confluent.io/current/schema-registry/docs/serializer-formatter.html#basic-auth-security)
184+
2. [sasl.*](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md)
68185

69-
[Schema Registry documentation](https://docs.confluent.io/current/schema-registry/docs/security.html#configuring-the-rest-api-for-http-or-https)
186+
The [Docker testconf](../docker/conf/testconf.json) and [Docker compose file](../docker/docker-compose.yaml) can be referenced as an example.
70187

71-
If client authentication has been enabled you will need to provide both the client certificate, `schema.registry.ssl.certificate.location`,
72-
and the client's private key, `schema.registry.ssl.key.location`
188+
**Note** The userinfo provided in the url and testconf members must have valid credentials as configured with the Schema Registry.
73189

74-
python examples/integration_test.py --avro-https --conf testconf.json
190+
#### Execute test
191+
python examples/integration_test.py --avro-basic-auth --conf testconf.json

tests/testconf-example.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
"topic": "<test-topic> or $MY_TOPIC_ENV",
33
"bootstrap.servers": "<bootstrap-brokers> or $MY_BOOTSTRAP_SERVER_ENV",
44
"schema.registry.url": "<schema-registry-url> or $MY_SCHEMA_REGISTRY_URL_ENV",
5-
"schema_registry_https": {
6-
"schema.registry.url": "<schema-registry-url> or $MY_SCHEMA_REGISTRY_SSL_URL_ENV",
7-
"schema.registry.ssl.ca.location": "/path/to/ca-cert or $MY_SCHEMA_REGISTRY_SSL_CA_LOCATION_ENV",
8-
"schema.registry.ssl.certificate.location": "/path/to/client.pem or $MY_SCHEMA_REGISTRY_SSL_CERTIFICATE_LOCATION_ENV",
9-
"schema.registry.ssl.key.location": "/path/to/client.key or $MY_SCHEMA_REGISTRY_SSL_KEY_LOCATION_ENV"
10-
}
11-
}
5+
"avro-https": {
6+
"schema.registry.url": "<schema-registry-url> or $MY_SCHEMA_REGISTRY_SSL_URL_ENV",
7+
"schema.registry.ssl.ca.location": "/path/to/ca-cert or $MY_SCHEMA_REGISTRY_SSL_CA_LOCATION_ENV",
8+
"schema.registry.ssl.certificate.location": "/path/to/client.pem or $MY_SCHEMA_REGISTRY_SSL_CERTIFICATE_LOCATION_ENV",
9+
"schema.registry.ssl.key.location": "/path/to/client.key or $MY_SCHEMA_REGISTRY_SSL_KEY_LOCATION_ENV"},
10+
"avro-basic-auth": {
11+
"schema.registry.basic.auth.user.info": "ckp_tester:test_secret",
12+
"sasl.username": "ckp_tester",
13+
"sasl.password": "test_secret"}
14+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy