Commit fd859210 authored by Eevans's avatar Eevans
Browse files

Importing initial dev/test environment

parent b5d96f5a
# This needs to match the service name in docker-compose.yml
SERVICE ?= cassandra
docker-compose run --rm $(SERVICE) cqlsh $(SERVICE)
for f in `ls bootstrap.d/*.cql`; do \
docker-compose run --rm $(SERVICE) cqlsh $(SERVICE) -f /env/$$f; \
docker-compose up --abort-on-container-exit
docker-compose down --remove-orphans
.PHONY: bootstrap cqlsh startup shutdown
# cassandra-env-scaffold
Scaffolding for projects that need a Cassandra development and/or testing environment.
## Requirements
- Docker & Docker Compose
- Make
On Debian-based systems, `apt install build-essential docker-compose` is probably sufficient.
## Usage
### Running
$ make startup
[ ... ]
cassandra_1 | INFO [main] 2021-10-22 15:03:13,459 - JOINING: Finish joining ring
cassandra_1 | INFO [main] 2021-10-22 15:03:13,616 - Waiting for gossip to settle...
cassandra_1 | INFO [main] 2021-10-22 15:03:21,617 - No gossip backlog; proceeding
cassandra_1 | INFO [main] 2021-10-22 15:03:21,977 - Netty using native Epoll event loop
cassandra_1 | INFO [main] 2021-10-22 15:03:22,048 - Using Netty Version: [netty-buffer=netty-buffer-4.0.44.Final.452812a, netty-codec=netty-codec-4.0.44.Final.452812a, netty-codec-haproxy=netty-codec-haproxy-4.0.44.Final.452812a, netty-codec-http=netty-codec-http-4.0.44.Final.452812a, netty-codec-socks=netty-codec-socks-4.0.44.Final.452812a, netty-common=netty-common-4.0.44.Final.452812a, netty-handler=netty-handler-4.0.44.Final.452812a, netty-tcnative=netty-tcnative-1.1.33.Fork26.142ecbb, netty-transport=netty-transport-4.0.44.Final.452812a, netty-transport-native-epoll=netty-transport-native-epoll-4.0.44.Final.452812a, netty-transport-rxtx=netty-transport-rxtx-4.0.44.Final.452812a, netty-transport-sctp=netty-transport-sctp-4.0.44.Final.452812a, netty-transport-udt=netty-transport-udt-4.0.44.Final.452812a]
cassandra_1 | INFO [main] 2021-10-22 15:03:22,048 - Starting listening for CQL clients on / (unencrypted)...
cassandra_1 | INFO [main] 2021-10-22 15:03:22,111 - Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it
cassandra_1 | INFO [main] 2021-10-22 15:03:22,111 - Startup complete
[ ... ]
Starts a single node Cassandra cluster as a container in the foreground and binds to
### Connecting with cqlsh
Running `cqlsh` from an (ephemeral) container:
$ make cqlsh
Or optionally, to run `cqlsh` from the host:
$ . py/bin/activate
$ cqlsh
_NOTE: Use `deactivate` to leave the Python virtual environment._
### Creating schema & loading test data
$ make bootstrap
The `bootstrap` target is a convenience that reads files with a `.cql` extension (in sort lexical order)
from `bootstrap.d`, and runs them with `cqlsh -f`.
### Shutting down
To terminate the service, remove all associated state and containers:
$ make shutdown
-- Create schema (keyspace & table)
CREATE KEYSPACE IF NOT EXISTS example WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
CREATE TABLE IF NOT EXISTS example.users (id text PRIMARY KEY, given text, surname text);
-- Import data from a comma-delimited file using COPY (INSERT/UPDATEs would work too)
COPY example.users FROM '/env/bootstrap.d/example_users.csv';
version: "3.4"
image: cassandra:3.11
- "9042:9042"
- .:/env
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment