Skip to content

Commit

Permalink
Add script to test TiSpark (#33)
Browse files Browse the repository at this point in the history
* Add script to test TiSpark

* Remove mysql test, use tispark-tests to test tidb connection
  • Loading branch information
liufuyang authored and tennix committed Jul 25, 2018
1 parent a51525f commit f30d7af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ services:
- docker

before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce # update docker version
- sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
- docker -v
- docker-compose -v
- docker-compose up -d
- sleep 5 # wait all components get ready
- sleep 10 # wait all components get ready
- docker-compose ps
- docker images
- docker network ls
- docker-compose logs

script:
- docker ps -a --format="{{.Names}} {{.Image}} {{.Status}}" | grep -v 'Up' | grep -v 'Exited (0)' | awk '{print} END {if (NR>0) {exit 1;}}'
- mysql -h 127.0.0.1 -P 4000 -u root -e "select tidb_version()\G" # test if tidb-server is working
- docker-compose -f docker-compose-test.yml run --rm tispark-tests bash /opt/spark/tests/loaddata.sh # add some data for tests
- docker-compose -f docker-compose-test.yml run --rm tispark-tests /opt/spark/bin/spark-submit /opt/spark/tests/tests.py # run tispark tests
13 changes: 13 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2.1'

services:
tispark-tests:
image: pingcap/tispark:latest
volumes:
- ./config/spark-defaults.conf:/opt/spark/conf/spark-defaults.conf:ro
- ./tispark-tests/tests:/opt/spark/tests:ro

networks:
default:
external:
name: tidb-docker-compose_default
5 changes: 5 additions & 0 deletions tispark-tests/tests/loaddata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd /opt/spark/data/tispark-sample-data

mysql -h tidb -P 4000 -u root < dss.ddl
12 changes: 12 additions & 0 deletions tispark-tests/tests/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pyspark.sql import SparkSession
import pytispark.pytispark as pti

spark = SparkSession.builder.master("spark://tispark-master:7077").appName("TiSpark tests").getOrCreate()

ti = pti.TiContext(spark)

ti.tidbMapDatabase("TPCH_001")

count = spark.sql("select count(*) as c from lineitem").first()['c']

assert 60175 == count

0 comments on commit f30d7af

Please sign in to comment.