Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup Cassandra container in Github Actions and query

I have this .yml file:

name: CasDB

on: push

env:
  CARGO_TERM_COLOR: always


jobs:
  test:
    runs-on: ubuntu-latest
    services:
      cassandra:
        image: cassandra
        ports:
          - 9042:9042
        options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
    steps:
      - run: docker ps
      - run: docker exec ${{ job.services.cassandra.id }} cqlsh --debug localhost:9042 --execute="use somekeyspace;"

I want in my Github actions to spin up a Cassandra database and than execute some queries. The Cassandra database is running, but when I want to execute a query ("use somekeyspace"), it fails with this error message:

Using CQL driver: <module ‘cassandra’ from ‘/opt/cassandra/bin/…/lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/init.py’> Using connect timeout: 5 seconds Using ‘utf-8’ encoding Using ssl: False Traceback (most recent call last): File “/opt/cassandra/bin/cqlsh.py”, line 2459, in main(*read_options(sys.argv[1:], os.environ)) File “/opt/cassandra/bin/cqlsh.py”, line 2437, in main encoding=options.encoding) File “/opt/cassandra/bin/cqlsh.py”, line 485, in init load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]), File “/opt/cassandra/bin/…/lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/policies.py”, line 417, in init socket.gaierror: [Errno -2] Name or service not known ##[error]Process completed with exit code 1.

What things I need to change in my .yml to:

  1. Execute a .sql script (multiple database scripts)
  2. Execute a single cqlsh statement

Thanks

like image 752
J. Doe Avatar asked Oct 24 '25 05:10

J. Doe


1 Answers

You are simply running cqlsh with wrong parameters: You cannot give it localhost:9042 as the hostname. The hostname and port are separate parameters. Try:

cqlsh localhost 9042

Instead of cqlsh localhost:9042.

like image 193
Nadav Har'El Avatar answered Oct 26 '25 18:10

Nadav Har'El



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!