forked from plotly/falcon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a90f483
commit 2651208
Showing
6 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { assert } from 'chai'; | ||
|
||
import { DIALECTS } from '../../app/constants/constants.js'; | ||
import { | ||
connect, | ||
query, | ||
schemas, | ||
tables | ||
} from '../../backend/persistent/datastores/Datastores.js'; | ||
|
||
const connection = { | ||
dialect: DIALECTS.CLICKHOUSE, | ||
host: 'localhost', | ||
port: 8123, | ||
username: 'default', | ||
database: 'plotly' | ||
}; | ||
|
||
describe('ClickHouse', function() { | ||
it('connect succeeds', function() { | ||
return connect(connection); | ||
}); | ||
|
||
it('tables returns list of tables', function() { | ||
return tables(connection).then(result => assert.include(result, 'consumption')) | ||
}); | ||
|
||
it('schemas returns schemas for all tables', function() { | ||
return schemas(connection).then(({ rows, columnnames }) => { | ||
assert.deepInclude(rows, ['consumption', 'alcohol', 'Float32']); | ||
assert.deepInclude(rows, ['consumption', 'location', 'String']); | ||
assert.deepEqual(columnnames, ['tablename', 'column_name', 'data_type']); | ||
}); | ||
}); | ||
|
||
it('query returns rows and column names', function() { | ||
return query( | ||
'SELECT * FROM consumption LIMIT 5', | ||
connection | ||
).then(({ rows, columnnames }) => { | ||
assert.deepEqual(rows, [ | ||
['Belarus', 17.5], | ||
['Moldova', 16.8], | ||
['Lithuania', 15.4], | ||
['Russia', 15.1], | ||
['Romania', 14.4] | ||
]); | ||
assert.deepEqual(columnnames, ['location', 'alcohol']); | ||
}); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM yandex/clickhouse-server:18.14 | ||
|
||
ADD https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv /2010_alcohol_consumption_by_country.csv | ||
|
||
RUN sed -i -e "1d" /2010_alcohol_consumption_by_country.csv | ||
|
||
RUN chmod 777 /2010_alcohol_consumption_by_country.csv | ||
|
||
RUN apt-get -y update && apt-get -y install curl clickhouse-client | ||
|
||
COPY setup.sh / | ||
|
||
RUN chmod +x /setup.sh | ||
|
||
EXPOSE 9000 8123 | ||
|
||
CMD /setup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The Dockerfile in this folder builds a Docker image that starts a ClickHouse server and sets up a test database. | ||
|
||
Will fill this out more tomorrow... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
clickhouse-server --config-file=/etc/clickhouse-server/config.xml & | ||
|
||
# Wait for ClickHouse server to be ready | ||
until $(curl --output /dev/null --silent --head --fail http://localhost:8123); do | ||
echo -e -n '.' | ||
sleep 2.5 | ||
done | ||
|
||
clickhouse-client --query="CREATE DATABASE plotly"; | ||
|
||
clickhouse-client --database=plotly --query="CREATE TABLE consumption (location String, alcohol Float32) ENGINE = Memory"; | ||
|
||
cat /2010_alcohol_consumption_by_country.csv | clickhouse-client --database=plotly --query="INSERT INTO consumption FORMAT CSV"; | ||
|
||
# Keep ClickHouse server alive | ||
while true | ||
do | ||
sleep 30 | ||
done |