Developer Guide - ytyou/ticktock GitHub Wiki

1. Quick Start

1.1. Setup the Development Environment

The quickest way to setup a development environment for TickTock is to run the official TickTock developer's container. You will need to install Docker Engine first. Assuming the Docker Engine is already installed, run

docker run -td --name tt-dev -h tt -p 3000:3000 -p 6181-6182:6181-6182 ytyou/tt-dev:latest

To get on to the Docker container, run,

docker exec -it tt-dev /bin/bash

1.2. Build from Source

Once you are inside the Docker container, you can find the TickTock source code under

/home/ticktock/src/ticktock

The code may not be up-to-date. To get the latest code, and build it with appropriate Makefile, e.g., on ubuntu/debian, do

cd /home/ticktock/src/ticktock
git pull
make -f Makefile.ubuntu clean all 

1.3. Running Tests

To run unit tests,

cd /home/ticktock/src/ticktock
bin/all_tests

To run integration tests, you need to first start the OpenTSDB in the container,

cd /home/ticktock/src/ticktock/scripts
./opentsdb.sh

Now open another terminal, get on the container, and run

cd /home/ticktock/src/ticktock
test/int_test.py

After the integration test is complete, you can stop the OpenTSDB by simply hit Ctrl-C. It will stop the OpenTSDB, but it will not stop the HBase that was started when you started OpenTSDB. To stop the hbase, and cleanup all its data,

cd /home/ticktock/src/ticktock/scripts
./stop-hbase.sh

You have to stop hbase before you can start another run of integration tests, so that no left-over data from last run remains.

1.4. Running TickTock

To run the TickTock server,

cd /home/ticktock/src/ticktock
bin/tt -c conf/tt.test.conf -d

To send metrics to it,

/opt/tcollector/tcollector start --port 6181

To view metrics in TickTock, point your browser to the docker host at port 3000.

1.5. Logs location and online setting

Logs are specified in the config file (e.g., conf/tt.test.conf).

# Logging level
; log.level = INFO

# Log file (full path)
log.file = /tmp/tt/log/ticktock.log

The default log location of ytyou/ticktock:latest docker is /var/lib/ticktock/log/ticktock.log .

Note that you can online update log.level by curl:

curl -XPOST "http://localhost:6182/api/admin?cmd=log&level=debug"

Your log file will output DEBUG level logs without restarting TickTock.

2. Setup Your Own Environment

Currently we support CentOS (or Redhat-based OS) and Ubuntu (or Debian-based OS) only.

2.1 Setup on CentOS (or Redhat-based OS)

First, install necessary tools and libraries,

yum install zlib-devel
yum groupinstall "Development Tools"

Then, under the root directory of the TickTock repo, run

make -f Makefile.centos clean all

2.2. Setup on Ubuntu (or Debian-based OS)

First, install necessary tools and libraries,

apt install zlib1g-dev
apt install build-essential

Then, under the root directory of the TickTock repo, run

make -f Makefile.ubuntu clean all