# Generating the Binary

**URL:** <https://discuss.elastic.co/t/generating-the-binary/32526>\
**Category:** Beats\
**Tags:** packetbeat\
**Created:** [October 19, 2015, 7:20pm UTC](https://discuss.elastic.co/t/generating-the-binary/32526 "2015-10-19T19:20:36Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 22, 2015, 7:46am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/22 "2015-10-22T07:46:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 22, 2015, 10:37am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/23 "2015-10-22T10:37:18Z")

</div>

- 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?

---

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 22, 2015, 4:13pm UTC](https://discuss.elastic.co/t/generating-the-binary/32526/24 "2015-10-22T16:13:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 22, 2015, 6:14pm UTC](https://discuss.elastic.co/t/generating-the-binary/32526/25 "2015-10-22T18:14:29Z")

</div>

Now I am back to the first question of how to generate the binary i.e. \*.test file in go code?

---

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 22, 2015, 10:07pm UTC](https://discuss.elastic.co/t/generating-the-binary/32526/26 "2015-10-22T22:07:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 23, 2015, 7:22am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/27 "2015-10-23T07:22:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 23, 2015, 7:37am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/28 "2015-10-23T07:37:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 23, 2015, 7:41am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/29 "2015-10-23T07:41:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Prerna\_Manaktala](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Prerna\_Manaktala](https://discuss.elastic.co/u/Prerna_Manaktala)\
**Post date:** [October 23, 2015, 8:04am UTC](https://discuss.elastic.co/t/generating-the-binary/32526/30 "2015-10-23T08:04:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 9:58pm UTC](https://discuss.elastic.co/t/generating-the-binary/32526/31 "2017-07-05T21:58:37Z")

</div>



[Previous page](https://discuss.elastic.co/t/generating-the-binary/32526.md?page=1)
