Skip to content

Commit

Permalink
Merge pull request #158 from dakimura/integtests-not-sorted-by-time
Browse files Browse the repository at this point in the history
add a test case of CSV Import
  • Loading branch information
rocketbitz authored Dec 7, 2018
2 parents f39ab3c + ceab137 commit 2c1ca30
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@
mktsdb/
marketstore
*.exe

# Python Virtual Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
57 changes: 48 additions & 9 deletions tests/integ/bin/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,85 @@
#!/bin/bash

function exit_if_failed()
{
if [[ $1 -ne 0 ]];
then
echo "Failed"
exit 1;
fi
}

# init data
rm -rf testdata test_ticks.csv && mkdir -p testdata/mktsdb
if [ $? -ne 0 ]; then exit 1; fi
if [ $? -ne 0 ]; then \
echo "Failed: cannot delete testdata and make testdata/mktsdb directory"
exit 1;
fi


# import ticks-example-1.csv/yaml to TEST/1Min/TICK and check if the output of show commands match ticks-example-1-output.csv
marketstore connect -d `pwd`/testdata/mktsdb <<- EOF
\create TEST/1Min/TICK:Symbol/Timeframe/AttributeGroup Bid,Ask/float32 variable
\getinfo TEST/1Min/TICK
\load TEST/1Min/TICK bin/ticks-example-1.csv bin/ticks-example-1.yaml
\o test_ticks.csv
\show TEST/1Min/TICK 1970-01-01
EOF
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

diff -q bin/ticks-example-1-output.csv test_ticks.csv && echo "Passed"
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

rm -f test_ticks.csv
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?


# import ticks-example-2.csv/yaml to TEST2/1Min/TICK and check if the output of show commands match ticks-example-2-output.csv
marketstore connect -d `pwd`/testdata/mktsdb <<- EOF
\create TEST2/1Min/TICK:Symbol/Timeframe/AttributeGroup Bid,Ask/float32 variable
\load TEST2/1Min/TICK bin/ticks-example-2.csv bin/ticks-example-2.yaml
\o test_ticks.csv
\show TEST2/1Min/TICK 1970-01-01
EOF
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

diff -q bin/ticks-example-2-output.csv test_ticks.csv && echo "Passed"
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

rm -f test_ticks.csv
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?


# import ticks-example-1.csv/yaml to TEST/1Min/TICK
# and check if the output of show commands match ticks-example-1-output.csv + ticks-example-2-output.csv
marketstore connect -d `pwd`/testdata/mktsdb <<- EOF
\load TEST2/1Min/TICK bin/ticks-example-1.csv bin/ticks-example-1.yaml
\o test_ticks.csv
\show TEST2/1Min/TICK 1970-01-01
EOF
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

cat bin/ticks-example-1-output.csv bin/ticks-example-2-output.csv > tmp.csv
diff -q tmp.csv test_ticks.csv && echo "Passed"
if [ $? -ne 0 ]; then exit 1; fi
exit_if_failed $?

rm -f test_ticks.csv
exit_if_failed $?


# import ticks-example-not-sorted-by-time.csv/yaml to TEST/1Min/TICK
# and check if the output of show commands match ticks-example-not-sorted-by-time-output.csv
marketstore connect -d `pwd`/testdata/mktsdb <<- EOF
\create TEST/1Min/TICK:Symbol/Timeframe/AttributeGroup Bid,Ask/float32 variable
\getinfo TEST/1Min/TICK
\load TEST/1Min/TICK bin/ticks-example-not-sorted-by-time.csv bin/ticks-example-not-sorted-by-time.yaml
\o test_ticks.csv
\show TEST/1Min/TICK 1970-01-01
EOF
exit_if_failed $?

diff -q bin/ticks-example-not-sorted-by-time-output.csv test_ticks.csv && echo "Passed"
exit_if_failed $?

# remove the temporary files
rm -rf testdata test_ticks.csv tmp.csv
3 changes: 3 additions & 0 deletions tests/integ/bin/ticks-example-not-sorted-by-time-output.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2018-11-21 01:23:44 +0000 UTC,112.8,112.8,999998994
2018-11-21 01:23:45 +0000 UTC,112.82,112.8,99999988
2018-11-21 01:32:00 +0000 UTC,112.81,112.8,0
4 changes: 4 additions & 0 deletions tests/integ/bin/ticks-example-not-sorted-by-time.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Epoch ,Bid, Ask
2018-11-21T01:23:44.999999,112.80,112.8
2018-11-21T01:32:00.000000,112.81,112.8
2018-11-21T01:23:45.100000,112.82,112.8
6 changes: 6 additions & 0 deletions tests/integ/bin/ticks-example-not-sorted-by-time.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
firstRowHasColumnNames: true
timeFormat: "2006-01-02T15:04:05.000000"
columnNameMap:
- Epoch
- Bid
- Ask

0 comments on commit 2c1ca30

Please sign in to comment.