- libswsscommon built and the library available on
LD_LIBRARY_PATH. Can be found at sonic-swss-common - follow the build instructions there. Must also setSWSSCOMMON_SRCto the full path to the directorysonic-swss-common. - libcswsscommon must be built, run make within
MSEE/libcswsscommonafter step 1. - Redis database on localhost:6379 - we use DB 0 (
APPL_DB) and 4 - Go version 1.8 (static binaries can be found at https://golang.org/dl/)
- Thrift to build mock server - Ubuntu will need to build from source https://g4greetz.wordpress.com/2016/10/29/how-to-install-apache-thrift-in-ubuntu/ - you may also need to add
/usr/local/libtoLD_LIBRARY_PATH - Python (2 or 3) with python-redis for the tests
- The following variables must be set
CGO_CFLAGS="-I(PATH_TO_NETWORKING_ACS_RESTAPI)/MSEE/libcswsscommon/include"
CGO_LDFLAGS="-L(PATH_TO_NETWORKING_ACS_RESTAPI)/MSEE/libcswsscommon -L(PATH_TO_LIBSWSSCOMMON_INSTALL)/lib"
LD_LIBRARY_PATH="(PATH_TO_NETWORKING_ACS_RESTAPI)/MSEE/libcswsscommon:(PATH_TO_LIBSWSSCOMMON_INSTALL)/lib"
The directories within the MSEE repo should be symlinked so that they follow the proper Go layout.
$GOPATH/src/go-server-server -> MSEE/go-server-server
$GOPATH/src/mseethrift -> MSEE/mseethrift
$GOPATH/src/mseethrifttest -> MSEE/mseethrifttest
$GOPATH/src/swsscommon -> MSEE/swsscommon
It should then be possible to run go get followed by go build within $GOPATH/src/go-server-server to build the go-server-server binary.
The Go server requires that it can connect to the Thrift server, we have a mock server that will allow every request to suceed, this will allow the Go server to run successfully.
To run the mock Thrift server run go run server.go within $GOPATH/src/mseethrifttest
The go-server-server binary supports several command line arguments.
-h - Lists command line arguments
-reset - Resets the cache DB (DB 4)
-macaddr=<mac> - Specifies switch MAC address (required)
-loaddr=<lo> - Specified switch loopback address (required)
-thrift=<host:port> - Specifies the host and port of the Thrift server, defaults to localhost:9090
In order to run the tests the Redis DB and mock Thrift server must be running. Once they are both running, start the go-server-server binary.
In another terminal run python -m unittest apitest within the MSEE/test directory to run the tests. Some tests will be skipped or expected to fail, this is expected due to the incomplete API at this time. There should be no unexpected failures.
If there are unexpected failures ensure that the Redis DB and mock Thrift servers are running.