Yes you are right Ruflin.
Can you please mention the commands I need to run and files I need to
create which you are referring to when you said that I need to create the
files mentioned in blog post.
- The first file is the main_test.go file inside the Golang project (which you already seem to have)
- Second I suggest to create your own Makefile to have all commands in one place to run the tests and collect the coverage files.
As we are now on the same page about not needing packetbeat, I think it gets now much easier to solve your problem.
What is the command you use to run your tests without the coverage binaries?
Great.
Do I need to have two makefiles?
One for sourcecode and one for tests like it is there in packetbeat?
Without packetbeat I run tests as :
./testrunner -i local.ini -t
tuqquery.tuq_2i_index.QueriesIndexTests.test_covering_index
where ini file has the server name ,username,password configurations.
Example:
[global]
port:8091
username:root
password:couchbase
index_port:9102
[servers]
1:SERVER_1
[SERVER_1]
ip:172.23.107.56
services=n1ql,kv,index
[membase]
rest_username:Administrator
rest_password:password
Now I am back to the first question of how to generate the binary i.e. *.test file in go code?
I am able to generate the .test file:
go test -c -covermode=atomic -cover -coverpkg=./server/... ./server/cbq-engine
called cbq-engine.test in the developer code.
Can anyone help me with the next steps.
./cbq-engine.test -test.coverprofile=coverage.cov -systemTest -debug -loglevel=debug -datastore=mock: -http=:8094 runs fine but I do not see any coverage.cov generated.
Looks like we are on the right path now.
The command looks fine and the coverage should be written to the directory cbq-engine.test is running in after closing the command. What is the content of your main_test.go file?
I was able to generate coverage.cov using ./cbq-engine.test -test.coverprofile=coverage.cov
without systemtests.
Now I need to use this coverage.cov in my python tests.How should I go about that?
Somewhere in your testrunner code you call the cbq-engine binary. This call you must now replace with the command you have above.
As your were able to generate a coverage without the systemTest flag, I assume something is not correct in your main_test.go file. It is good to hear that coverage is generated but I think you will run into issues either when running the normal tests or in your system tests.
Can you post the content of your main_test.go or link to it?
sure: main_test.go has:
package main
// This file is mandatory as otherwise the filebeat.test binary is not generated correctly.
import (
"testing"
"flag"
)
var systemTest *bool
func init() {
systemTest = flag.Bool("systemTest", false, "Set to true when running system tests")
}
// Test started when the test binary is started. Only calls main.
func TestSystem(t *testing.T) {
if *systemTest {
main()
}
}
~
I have placed this in path:/Users/prernamanaktala/work/src/github.com/couchbase/query/server/cbq-engine
but I have tests in /Users/prernamanaktala/work/src/github.com/couchbase/query/test/multistore
and other folders within query/test also.
So do I need to copy this main_test.go to every folder I have tests since coverpkg path changes accordingly.
go test -c -covermode=atomic -cover -coverpkg=./server/... ./server/cbq-engine