cassandra/pylib
Leonard Ma a2dc44f072
Remove dependency on pytz library for setting CQLSH timezones on Python version >= 3.9
patch by Leonard Ma; reviewed by Brad Schoening, Brandon Williams and Stefan Miklosovic for CASSANDRA-17433
2023-06-05 21:13:30 +02:00
..
cqlshlib Remove dependency on pytz library for setting CQLSH timezones on Python version >= 3.9 2023-06-05 21:13:30 +02:00
Dockerfile.ubuntu.py3 Allow cqlsh to run with Python 2.7/Python 3.6+ 2020-04-14 20:58:40 +02:00
Dockerfile.ubuntu.py37 Allow cqlsh to run with Python 2.7/Python 3.6+ 2020-04-14 20:58:40 +02:00
Dockerfile.ubuntu.py38 Allow cqlsh to run with Python 2.7/Python 3.6+ 2020-04-14 20:58:40 +02:00
README.asc update Python test framework from nose to pytest 2022-02-20 17:32:11 +01:00
cassandra-cqlsh-tests.sh Prepare for JDK17 experimental support 2023-02-12 20:43:46 +01:00
requirements.txt replace local wcwidth.py with pypi module 'wcwidth' 2022-11-14 06:23:18 -06:00
setup.py Change shebangs of Python scripts to resolve Python 3 from env command 2022-11-18 14:38:03 +01:00

README.asc

== Overview

This directory contains code primarily for cqlsh. cqlsh uses cqlshlib in this directory.

== Requirements
. Python 3.6+ (for cqlsh)
. virtualenv
. Docker (optional)

== Running tests

The following environment variables can be configured for the database connection -

. CQL_TEST_HOST, default 127.0.0.1
. CQL_TEST_PORT, default 9042
. CQL_TEST_USER, default 'cassandra'
. CQL_TEST_PWD

You can run tests with a local Cassandra server simply by -

  $ pytest

In order to run tests in a virtual environment for cqlshlib, run cassandra-cqlsh-tests.sh in this directory. It will
automatically setup a virtualenv with the appropriate version of Python and run tests inside it.

There are Dockerfiles that can be used to test whether cqlsh works with a default, barebones
Python installation. Assuming Cassandra's source is checked out at `$CASSANDRA_DIR`. To test, first
build the Docker image containing the barebones Python installation -

  $ docker build . --file Dockerfile.ubuntu.py3 -t ubuntu-lts-py3

Next, run cqlsh inside the newly built image -

  $ docker run -v $CASSANDRA_DIR:/code -it ubuntu-lts-py3:latest /code/bin/cqlsh host.docker.internal

If `host.docker.internal` isn't supported, then you can use `--net="host"` with `docker run`:

  $ docker run --net="host" -v $CASSANDRA_DIR:/code -it ubuntu-lts-py3:latest /code/bin/cqlsh

This will try to spawn a cqlsh instance inside the Docker container running Ubuntu LTS (18.04)
with minimal Python installation. It will try to connect to the Cassandra instance running on the
Docker host at port 9042. If you have Cassandra running elsewhere, replace host.docker.internal
with the IP / hostname as usual. Please ensure that the IP / host is accessible from _within_ the
Docker container.