Provides a new Kudu client as a pytest fixture. The client only exists for the duration of the method it is used in.
(request)
| 429 | |
| 430 | @pytest.fixture |
| 431 | def kudu_client(request): |
| 432 | """Provides a new Kudu client as a pytest fixture. The client only exists for the |
| 433 | duration of the method it is used in. |
| 434 | """ |
| 435 | kudu_master = request.config.option.kudu_master_hosts |
| 436 | |
| 437 | if "," in kudu_master: |
| 438 | raise Exception("Multi-master not supported yet") |
| 439 | if ":" in kudu_master: |
| 440 | host, port = kudu_master.split(":") |
| 441 | else: |
| 442 | host, port = kudu_master, DEFAULT_KUDU_MASTER_PORT |
| 443 | kudu_client = kudu_connect(host, port) |
| 444 | yield kudu_client |
| 445 | |
| 446 | try: |
| 447 | kudu_client.close() |
| 448 | except Exception as e: |
| 449 | LOG.warn("Error closing Kudu client: %s", e) |
| 450 | |
| 451 | |
| 452 | @pytest.fixture(scope="class") |