-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
130 lines (106 loc) · 3.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Copyright 2020 OmniSci, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile to call the basic rust, cargo and docker commands
#
SHELL = /bin/sh
.DEFAULT_GOAL=all
OMNISCI_VERSION = v5.6.4
OMNISCI_IMAGE = omnisci/core-os-cpu:${OMNISCI_VERSION}
# OMNISCI_IMAGE = omnisci/omnisci-ee-cuda:${OMNISCI_VERSION}
# OMNISCI_IMAGE = omnisci-log-scraper-build
DB_CONTAINER = omnisci-test-db
-include .env
deps:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
.PHONY: deps
build:
cargo build
.PHONY: build
run:
cargo run tests/omnisci_server.INFO
.PHONY: run
test_lib:
mkdir -p target/test
mkdir -p target/test2
cargo test
# diff -d tests/gold/copy_to_omnisci_log_scraper.csv target/test/copy_to_omnisci_log_scraper.csv
# diff -d tests/gold/copy_to_omnisci_log_scraper.csv target/test2/copy_from_to_omnisci_log_scraper.csv
.PHONY: test_lib
test_gold:
mkdir -p target/test
# write various types of output to files in target/test
cargo run -- -t csv --hostname db --output target/test tests/gold/omnisci_server.INFO
cargo run -- -t sql tests/gold/omnisci_server.INFO > target/test/omnisci_server.INFO.sql
cargo run -- -f select -t sql tests/gold/omnisci_server.INFO > target/test/omnisci_server.INFO-select.sql
cargo run -- -t terminal tests/gold/omnisci_server.INFO > target/test/omnisci_server.INFO.terminal.txt
# then compare them to expected output
diff tests/gold/omnisci_server.INFO.csv target/test/omnisci_server.INFO.csv
diff tests/gold/omnisci_server.INFO.sql target/test/omnisci_server.INFO.sql
diff tests/gold/omnisci_server.INFO-select.sql target/test/omnisci_server.INFO-select.sql
diff tests/gold/omnisci_server.INFO.terminal.txt target/test/omnisci_server.INFO.terminal.txt
.PHONY: test_gold
test: test_lib test_gold
.PHONY: test
test_ignored:
cargo test -- --ignored
.PHONY: test_ignored
test_all: test test_ignored
.PHONY: test_all
# Run this after validating the changes to output in target/test are expected
test_update_gold:
cp -R target/test/*.* tests/gold/
.PHONY: test_update_gold
install:
cargo install --path .
.PHONY: install
release:
cargo build --release
.PHONY: release
all: test
.PHONY: all
#
# Docker
#
deps.docker:
# cd docker && ./buildbinary.sh
docker build -t omnisci-log-scraper-build docker
.PHONY: deps.docker
build.docker: deps.docker
docker run -i -v ${PWD}:/src -w /src omnisci-log-scraper-build \
/root/.cargo/bin/cargo build --release --target-dir target/ubuntu
echo "See target/ubuntu/release/ for the omnisci-log-scraper binary"
.PHONY: build.docker
up:
mkdir -p target/${DB_CONTAINER}
@echo "verbose = true" > target/${DB_CONTAINER}/omnisci.conf
@echo "log-severity = DEBUG4" >> target/${DB_CONTAINER}/omnisci.conf
@echo "allowed-import-paths = [\"/src\", \"/omnisci-storage/data\"]" >> target/${DB_CONTAINER}/omnisci.conf
@echo "allowed-export-paths = [\"/src\"]" >> target/${DB_CONTAINER}/omnisci.conf
docker run --name ${DB_CONTAINER} \
-d --rm \
-v ${PWD}:/src \
-v ${PWD}/target/${DB_CONTAINER}:/omnisci-storage \
-p 46273-46274:6273-6274 \
-e CUDA_VISIBLE_DEVICES="0,1" \
${OMNISCI_IMAGE} \
/omnisci/startomnisci --non-interactive --data /omnisci-storage/data --config /omnisci-storage/omnisci.conf
.PHONY: up
stop:
docker stop ${DB_CONTAINER}
.PHONY: stop
down:
docker stop ${DB_CONTAINER} || echo "container not running"
# docker rm -f ${DB_CONTAINER}
.PHONY: down