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
cqlsh:
docker-compose run --rm $(SERVICE) cqlsh $(SERVICE)
bootstrap:
for f in `ls bootstrap.d/*.cql`; do \
docker-compose run --rm $(SERVICE) cqlsh $(SERVICE) -f /env/$$f; \
done
startup:
docker-compose up --abort-on-container-exit
shutdown:
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 StorageService.java:1564 - JOINING: Finish joining ring
cassandra_1 | INFO [main] 2021-10-22 15:03:13,616 Gossiper.java:1832 - Waiting for gossip to settle...
cassandra_1 | INFO [main] 2021-10-22 15:03:21,617 Gossiper.java:1863 - No gossip backlog; proceeding
cassandra_1 | INFO [main] 2021-10-22 15:03:21,977 NativeTransportService.java:68 - Netty using native Epoll event loop
cassandra_1 | INFO [main] 2021-10-22 15:03:22,048 Server.java:158 - 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 Server.java:159 - Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)...
cassandra_1 | INFO [main] 2021-10-22 15:03:22,111 CassandraDaemon.java:564 - 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 CassandraDaemon.java:650 - Startup complete
[ ... ]
Starts a single node Cassandra cluster as a container in the foreground and binds to 0.0.0.0:9042.
### 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';
epresley,Elvis,Presley
jericevans,Eric,Evans
version: "3.4"
services:
cassandra:
image: cassandra:3.11
ports:
- "9042:9042"
volumes:
- .:/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