owl

command module
v3.15.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

Open-Falcon Backend

Open-Falcon

Build Status codecov GoDoc Go Report Card License

Documentations

Get Started

Start MySQL and Redis using docker

cd docker
docker-compose -f init.yml up -d
docker inspect docker_mysql_1
docker inspect docker_redis_1
cd ..

Change your environment setting

vi config/confgen.sh

Start Backend modules

make clean all pack
mkdir out
mv open-falcon-v2.0.0.tar.gz out/
cd out
tar zxvf open-falcon-v2.0.0.tar.gz
./open-falcon start agent graph transfer hbs fe query

Building from source

Binary

# all modules
make all

# specified module
make agent

Docker image

Use docker build at project root, for example:

docker build -t <image_name>:<image_tag> -f docker/alpine/Dockerfile .

Run Open-Falcon Commands

Agent for example:

./open-falcon agent [build|pack|start|stop|restart|status|tail]

Package Management

We use govendor to manage the golang packages. Please install govendor before compilation.

go get -u github.com/kardianos/govendor

Most depended packages are saved under ./vendor dir. If you want to add or update a package, just run govendor fetch xxxx@commitID or govendor fetch xxxx@v1.x.x, then you will find the package have been placed in ./vendor correctly.

Make sure you're using Go 1.5+ and GO15VENDOREXPERIMENT=1 env var is exported. (export GODEBUG=cgocheck=0 using Go 1.6+.)

Package Release

make clean all pack

Upgrading of MySql databases

See scripts/mysql/README.md

Testing

There are environment variables could be used to set-up properties for testing:

  • $OWL_TEST_PROPS_FILE - File name of properties
  • $OWL_TEST_PROPS - Property content as single string
  • $OWL_TEST_PROPS_SEP - Seperator to split record of property content in $OWL_TEST_PROPS

For example, you could use make go-test by:

OWL_TEST_PROPS="mysql.owl_portal=root:cepave@tcp(192.168.20.50:3306)/falcon_portal_test?parseTime=True&loc=Local" make go-test GO_TEST_VERBOSE=yes GO_TEST_FOLDER="modules/mysqlapi/rdb/owl"

Or use go test:

OWL_TEST_PROPS="mysql.owl_portal=root:cepave@tcp(192.168.20.50:3306)/falcon_portal_test?parseTime=True&loc=Local" go test ./modules/mysqlapi/rdb/owl -test.v

GOMAXPROCS(-parallel)

Since some tests(e.x. database unit test) are stateful, these tests should be run in single thread:

  1. GOMAXPROCS=<n> - By environment variable
  2. -parallel <n> - By test flags

See go help testflag for detail information.

Example:

OWL_TEST_PROPS="mysql.owl_portal=root:cepave@tcp(192.168.20.50:3306)/falcon_portal_test?parseTime=True&loc=Local mysql.graph=root:cepave@tcp(192.168.20.50:3306)/graph?parseTime=True&loc=Local"

# By $GOMAXPROCS
GOMAXPROCS=1 go test ./modules/mysqlapi/...

# By -parallel
go test -parallel 1 ./modules/mysqlapi/...

By using make go-test

Variables:

  • GO_TEST_FOLDER - The inclusions of folders(recursively probed) to be tested
  • GO_TEST_EXCLUDE - The exclusions of folders(include children), which are descendants of GO_TEST_FOLDER
  • GO_TEST_PROPS_FILE - If the value is viable, the execution of "go test" would have additional arguments -owl.test.propfile=<GO_TEST_PROPS_FILE>
  • GO_TEST_PROPS - If the value is viable, the execution of "go test" would have additional arguments -owl.test=<GO_TEST_PROPS>
  • GO_TEST_PROPS_SEP - If the value is viable, the execution of "go test" would have additional arguments -owl.test.sep=<GO_TEST_PROPS_SEP>
  • GO_TEST_FLAGS - If the value is viable, the execution of "go test" would have additional flags <flags...>
  • GO_TEST_VERBOSE - If the value is "yes", the execution of "go test -test.v"(with additional flags of 3-party frameworks) would be applied
  • GO_TEST_COVERAGE_FILE - If the value is viable, the execution of "go test" would be added with -coverprofile <file>
# Default execution
make go-test GO_TEST_FOLDER="modules common" GO_TEST_EXCLUDE="modules/fe modules/f2e-api"

# With MySql property and verbose output
make go-test GO_TEST_FOLDER="modules common" GO_TEST_EXCLUDE="modules/fe modules/f2e-api" GO_TEST_VERBOSE=yes GO_TEST_PROPS="mysql.owl_portal=root:cepave@tcp(192.168.20.50:3306)/falcon_portal_test?parseTime=True&loc=Local"

See Makefile for default values of the two variables.

In fact, the Makefile uses go-test-all.sh to perform go-test.

By using go-test-all.sh

This script would try to detect the importing of "common/testing/" in *_test.go files.

If the configuration is matched, this script would append -owl.test.propfile, -owl.test, or -owl.test.sep flags.

Arguments:

  • -t <folders> - The inclusions of folders(recursively probed) to be tested
  • -e <folders> - The exclusions of folders(include children), which are descendants of GO_TEST_FOLDER
  • -f <args> - If the value is viable, the execution of "go test" would have additional arguments -owl.test.propfile=<args>
  • -p <args> - If the value is viable, the execution of "go test" would have additional arguments -owl.test=<args>
  • -s <args> - If the value is viable, the execution of "go test" would have additional arguments -owl.test.sep=<args>
  • -a <flags> - If the value is viable, the execution of "go test" would have additional flags <flags>
  • -v - If this flag is shown, the execution of go test -test.v(with additional flags of 3-party frameworks) would be applied
  • -c <file> - If this flag is shown, the -coverprofile <file> would be set
# Default execution
./go-test-all.sh -t "modules common" -e "modules/fe modules/f2e-api"

# With MySql property and verbose output
./go-test-all.sh -t "modules common" -e "modules/fe modules/f2e-api" -v -p "mysql.owl_portal=root:cepave@tcp(192.168.20.50:3306)/falcon_portal_test?parseTime=True&loc=Local"

Usage of property file

Example of property file("sample.properties"):

mysql.owl_portal=root:cepave@tcp(192.168.20.50:3307)/falcon_portal
client.http.host=127.0.0.1
client.http.port=6040

Execute by go-test-all.sh:

OWL_TEST_PROPS_FILE="$PWD/sample.properties" ./go-test-all.sh -t "modules/mysqlapi/restful"

Documentation

Overview

build !release

Directories

Path Synopsis
common
cron
This package provides scheduled(by interval) service for jobs.
This package provides scheduled(by interval) service for jobs.
db
gin
Some convenient utility for usage of gin framework JSON service ginConfig := &GinConfig{ Mode: gin.ReleaseMode, Host: "localhost", Port: 8080, } engine := NewDefaultJsonEngine(ginConfig) // Start service // StartServiceOrExit(engine, ginConfig) // Binds the engine into existing HTTP service http.Handle("/root-service", engine) Panic in Code By using of "NewDefaultJsonEngine()", any panic code would be output as: { "http_status": 500, "error_code": -1, "error_message": fmt.Sprintf("%v", panicObject), } And the HTTP engine would keep running.
Some convenient utility for usage of gin framework JSON service ginConfig := &GinConfig{ Mode: gin.ReleaseMode, Host: "localhost", Port: 8080, } engine := NewDefaultJsonEngine(ginConfig) // Start service // StartServiceOrExit(engine, ginConfig) // Binds the engine into existing HTTP service http.Handle("/root-service", engine) Panic in Code By using of "NewDefaultJsonEngine()", any panic code would be output as: { "http_status": 500, "error_code": -1, "error_message": fmt.Sprintf("%v", panicObject), } And the HTTP engine would keep running.
gin/mvc
A MVC binder for free-style of function handler with *gin.Context Abstract There are may tedious processes for coding on web service: 1.
A MVC binder for free-style of function handler with *gin.Context Abstract There are may tedious processes for coding on web service: 1.
http
This package provides out-of-box configuration for initializing client object to calling of RESTful API services.
This package provides out-of-box configuration for initializing client object to calling of RESTful API services.
net
Provides various utilities to construct listener
Provides various utilities to construct listener
os
rpc
runtime
Because go language does not have industrial level of exception handing mechanism, using the information of calling state is the only way to expose secret in code.
Because go language does not have industrial level of exception handing mechanism, using the information of calling state is the only way to expose secret in code.
testing/check
This package provindes extensions to "gopkg.in/check.v1".
This package provindes extensions to "gopkg.in/check.v1".
testing/db
The base environment for RDB testing Flags This package has pre-defined flags of command: -dsn_mysql - MySQL DSN used to intialize configuration of mysql connection
The base environment for RDB testing Flags This package has pre-defined flags of command: -dsn_mysql - MySQL DSN used to intialize configuration of mysql connection
testing/flag
Provides unified interface to access needed flags when you are testing.
Provides unified interface to access needed flags when you are testing.
testing/http
Provides both HTTP client and HTTP fake server configuration for testing.
Provides both HTTP client and HTTP fake server configuration for testing.
testing/http/gock
Out-of-box Gock/Gentleman functions.
Out-of-box Gock/Gentleman functions.
testing/http/gock_plugin
Plugin for using Gock on Gentleman library.
Plugin for using Gock on Gentleman library.
textbuilder
This package provides lazy-loading and postfix binding for text building.
This package provides lazy-loading and postfix binding for text building.
types
This package provides out-of-box conversion service.
This package provides out-of-box conversion service.
utils
This package provides misc utilities.
This package provides misc utilities.
g
modules
fe
fe/grpc/proto/owlquery
Package owlapi is a generated protocol buffer package.
Package owlapi is a generated protocol buffer package.
hbs
query/grpc/proto/owlquery
Package owlapi is a generated protocol buffer package.
Package owlapi is a generated protocol buffer package.
scripts
mysql/dbpatch/go/changelog
As the loading process for change log
As the loading process for change log
mysql/dbpatch/go/sql
Connect and execute patch
Connect and execute patch
sdk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL