qiniu / goc Goto Github PK
View Code? Open in Web Editor NEWA Comprehensive Coverage Testing System for The Go Programming Language
License: Apache License 2.0
A Comprehensive Coverage Testing System for The Go Programming Language
License: Apache License 2.0
Now, when get profile using "force" tag, it may get a strange response: "no profile". It should be an error or nothing back.
e.g goc profile --summary
which can print the summary coverage rate
It's time to do some performance test now, and provide the report in README or doc.
go build/install
vs goc build/install
on some large project.goc profile
with several covered binarygoc profile
1 HZ, in count/set/atomic modeIf the tested service exit before goc profile
get the coverage file, goc profile
will write the error message instead:
goc profile output:
{"error":"Get http://127.0.0.1:38102/v1/cover/profile: dial tcp 127.0.0.1:38102: connect: connection refused"}
expected:
$ goc profile --address=http://127.0.0.1:9999 --coverfile="service*",'?!thrift_gen*' -o=coverage.out
FATA Goc server http://127.0.0.1:7777 return an error: {"error":"failed to filter profile based on the patterns: [service* ?!thrift_gen*], error: filterProfile failed with pattern ?!thrift_gen* for profile git.byted.org/ee/lark/facade/sticker/database/abase_sticker_set.go, err: error parsing regexp: missing argument to repetition operator: ?
"}
可以看到,使用 ?!thrift_gen* 正则来排除 thrift_gen 下的文件时,就有报错了
Nice tool!
I'm trying to use the goc tool by following the instructions of the gif in readme. But the output is unexpected.
First of all, I have installed goc tool through go get
command and git clone
the simple-go-server.
Then, goc run .
looks great.
But the output of goc profile
is not exactly the same as gif, and goc profile --center="http://127.0.0.1:52943" > coverage.out && go tool cover -func="coverage.out"
throws a 'can't find package 'error.
The log is showed below:
➜ simple-go-server git:(master) ✗ goc run .
[goc] goc server started: http://127.0.0.1:52943
http: 2020/07/08 14:14:29 Simple go server
http: 2020/07/08 14:14:29 Version:
http: 2020/07/08 14:14:29 GitTag:
http: 2020/07/08 14:14:29 GitCommit:
http: 2020/07/08 14:14:29 GitTreeState:
http: 2020/07/08 14:14:29 Server is starting...
http: 2020/07/08 14:14:29 Server is ready to handle requests at :5000
➜ simple-go-server git:(master) ✗ goc profile --center="http://127.0.0.1:52943"
mode: count
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:30.13,48.33 13 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:48.33,50.3 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:52.2,65.12 5 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:65.12,74.46 7 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:74.46,76.4 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:77.3,77.14 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:80.2,82.79 3 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:82.79,84.3 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:86.2,87.34 2 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:90.27,91.71 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:91.71,92.24 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:92.24,95.4 2 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:96.3,99.35 4 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:103.29,104.71 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:104.71,105.38 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:105.38,108.4 2 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:109.3,109.47 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:113.66,114.46 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:114.46,115.72 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:115.72,116.17 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:116.17,118.12 2 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:118.12,120.6 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:121.5,121.81 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:123.4,123.24 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:128.75,129.46 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:129.46,130.72 1 1
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:130.72,132.23 2 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:132.23,134.5 1 0
_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4/main.go:135.4,137.41 3 0
➜ simple-go-server git:(master) ✗ goc profile --center="http://127.0.0.1:52943" > coverage.out && go tool cover -func="coverage.out"
cover: cannot find package "_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4" in any of:
/usr/local/go/src/_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4 (from $GOROOT)
/Users/huangkuan/go/src/_/private/var/folders/wb/hmpbbl7j1jz74t843mxs7wqh0000gn/T/goc-build-ef63a484ffd4 (from $GOPATH)
Did I miss any steps in the gif?
Any suggestions will be appreciated :)
Currently, if the flag --debug
is false, goc install .
command wouldn't output any logs even it failed to execute. The behavior is absolutely unfriendly, we need enhance it.
大家好,README当中的微信群聊二维码似乎已经过期了,各位已经入群的朋友有时间的话可否更新一下?感谢。
// memoryStore holds the registered services only into memory
type memoryStore struct {
mu sync.RWMutex
servicesMap map[string][]string
}
// Get returns all the registered service information
func (l *memoryStore) GetAll() map[string][]string {
l.mu.RLock()
defer l.mu.RUnlock()
return l.servicesMap
}
Proposal:
运行提示cannot read property 'toString' of null
From: https://testerhome.com/topics/24515
Problems probably in: https://github.com/qiniu/goc/blob/master/pkg/cover/instrument.go#L254
we need adjust the logic。
As the title, thanks
error log:
[2020-06-04T17:49:02.521244021+0800] INFO: goc diff and display in github comment
time="2020-06-04T17:49:02+08:00" level=error msg="Get PR changed file failed. repoOwner is: qbox, repoName is: kodo, prNum is: 2781"
time="2020-06-04T17:49:02+08:00" level=fatal msg="Get pull request changed file failed." error="Get https://api.github.com/repos/qbox/kodo/pulls/2781/files?page=1: dial tcp 13.250.168.23:443: connect: connection refused"
The binary name should be generate from import path, not the directory path for gomodule project.
go list ./... some packages with ld warning info:
ld: warning: ld: warning: object file (/var/folders/8c/hk9slbfs25lbn_3z8rl7jqkr0000gn/T/go-link-210771923/000000.o) was built for newer OSX version (10.15) than being linked (10.13)object file (/var/folders/8c/hk9slbfs25lbn_3z8rl7jqkr0000gn/T/go-link-210771923/go.o) was built for newer OSX version (10.15) than being linked (10.13)
ld: warning: object file (/var/folders/8c/hk9slbfs25lbn_3z8rl7jqkr0000gn/T/go-link-210771923/000001.o) was built for newer OSX version (10.15) than being linked (10.13)
{
"Dir": "/Users/lei.liu/qbox/src/qiniu.com/pili-cluster/src/qiniu.com/pili.v1/app/pili-aliasyncauth",
"ImportPath": "qiniu.com/pili.v1/app/pili-aliasyncauth",
"Name": "main",
..........
}
RT
If errors occur when we use goc profile --output output.txt
to get a profile, we found that there is nothing warning on the terminal screen. But the errors appeared unexpectedly in the output file.
Like go
➜ goplus git:(0701) go version
go version go1.14.4 darwin/amd64
Goc should also have version management when publishing.
各位贡献者,你们好!
这是一个超棒的工具!
我在使用的过程中,发现我设定固定监听端口没有生效,我是这样的一个过程:
1、首先启动server
2、执行命令goc build --agentport :8080 --debug .
3、goc run .
发现端口还是随机生成的54776,并不是刚才注册的8080端口。
是不是我漏掉了某些步骤?
然后我有用goc init重置配置,具体步骤如下:
1、执行goc init
2、执行goc register -a "http://127.0.0.1:8080" -n simple-go-server --debug
3、然后再执行 goc build --agentport :8080 --debug . && goc run .
发现端口还是随机生成的!
最后用8080端口请求数据,发现报错,且返回为空:
请大家指导~~~🌹
收集了一堆覆盖率数据,想清除之前的重新收集,执行goc clear似乎无效
[user_00@user]$ goc clear
Register service aaa: http://127.0.0.1:57832 coverage counter clear call successfully
Register service bbb: http://127.0.0.1:51907 coverage counter clear call successfully
再次执行goc profile,仍然有覆盖率数据
杀掉goc server进程,重新打开,仍然有覆盖率数据
不知道是不是我理解错了,还是要用其他的方式清除数据?
麻烦更新下交流群二维码,谢谢
想问下,有相关 goc 的原理/架构设计相关的介绍吗?在线求
xxxxMacBook-Pro:~ xxxx$ go get -u github.com/qiniu/goc
xxx/src/github.com/hashicorp/go-retryablehttp/roundtripper.go:48:16: undefined: errors.Unwrap
xxxx/src/github.com/qiniu/goc/pkg/build/tmpfolder.go:86:5: undefined: errors.Is
for example, goc build .
would print the following information when it works normally, which is noisy:
2020/05/29 19:58:02 cover.go:114: go list cmd is: [go list -json . ./...]
2020/05/29 19:58:02 tmpfolder.go:65: Temp project generated in: /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-7af393cb71aa
2020/05/29 19:58:03 tmpfolder.go:78: New working/building directory in: /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-7af393cb71aa
2020/05/29 19:58:03 tmpfolder.go:47: New GOPATH:
2020/05/29 19:58:03 cover.go:114: go list cmd is: [go list -json . ./...]
2020/05/29 19:58:03 cover.go:89: handle package: github.com/qiniu/goc
2020/05/29 19:58:03 build.go:61: Go building in temp...
2020/05/29 19:58:06 build.go:76: Go build exit successful.
2020/05/29 19:58:06 binarymove.go:55: Generating binary: /Users/jicarl/qiniu/goc-1/goc
i think keeping the behavior of goc consistent with pure go command will make user more easier to use goc. not only goc build
needs to be modified, but others as well.
Steps:
➜ simple-go-server git:(master) echo $GOPATH
/Users/jicarl/k8s
➜ simple-go-server git:(master) pwd
/Users/jicarl/qbox/simple-go-server
➜ simple-go-server git:(master) git remote -v
origin [email protected]:enricofoltran/simple-go-server.git (fetch)
origin [email protected]:enricofoltran/simple-go-server.git (push)
➜ simple-go-server git:(master)
➜ simple-go-server git:(master) goc build .
2020/05/24 15:15:29 cover.go:114: go list cmd is: [go list -json . ./...]
2020/05/24 15:15:29 tmpfolder.go:65: Temp project generated in: /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-055cb24d8755
2020/05/24 15:15:29 tmpfolder.go:78: New working/building directory in: /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-055cb24d8755/Users/jicarl/qbox/simple-go-server
2020/05/24 15:15:29 tmpfolder.go:47: New GOPATH: /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-055cb24d8755:/Users/jicarl/k8s
2020/05/24 15:15:29 cover.go:114: go list cmd is: [go list -json . ./...]
2020/05/24 15:15:29 build.go:61: Go building in temp...
2020/05/24 15:15:29 build.go:74: Fail to execute: go build .. The error is: chdir /var/folders/_6/t59gxn4d0zz12vqlm3j3gwhr0000gn/T/goc-055cb24d8755/Users/jicarl/qbox/simple-go-server: no such file or directory, the stdout/stderr is:
Some services run virtualized environment such as docker container. The registered service can expose fixed port, making them a relatively easy method of integration across virtualized container and service center
项目比较大,各种依赖很复杂,有十几个文件,之前都是用makefile编译的
执行goc build .报错
go: $path/[email protected]: parsing $path/go.mod: open $path/go.mod: no such file or directory
FATA Fail to build: fail to execute: [/bin/bash -c go build -o $path/$program .], err: exit status 1
试了下用go build .可以成功编译
D:\workspace\simple-go-server (master -> origin)
λ goc build .
level=fatal msg="Fail to build: fail to list package dependencies"
sonar-scan can't parse the coverage.out generated by 'goc profile'
ERROR:
INFO: Load project repositories (done) | time=18ms
INFO: Load coverage report from '/xxx/coverage.out'
ERROR: Error parsing coverage info for file /xxx/coverage.out: Invalid go coverage, expect 'mode:' on the first line.
INFO: Sensor SonarGo [go] (done) | time=523ms
template with one blank in instrument.go
mux.HandleFunc("/v1/cover/profile", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "mode: {{.Mode }} \n")
最近有在尝试使用,几个问题望解答
1、使用goc build --center="http://127.0.0.1:7777" 编译后,如果goc的server没有启动,那么我编译后的服务,是否也无法启动?(我当前有这个问题)是否就是这样设计的?
2、register到center上是否只在服务启动的时候才注册?
3、当我的服务重启之后,注册在goc server上的信息不会remove,然后我goc profile或者goc clear 都会报错。当然,goc profile可以-f来强行获取,但是clear不行。
4、是否可以来一个remove的命令,让我对server上已经失去联系的服务自动进行清除。(如果不清理,以为着看你上面的信息会很多很多)
5、clear现在只有针对center的,是否可以提供针对service的clear?
6、覆盖率的数据是存在我自己的服务侧的,所以重启服务,或者服务突然down掉后,覆盖率数据就没有了,会重新开始收集?
RT, 貌似目前goc build时无法支持指定main包的位置
在使用go test 做覆盖率时,有go test -coverpkg可以指定覆盖率只统计哪些目录。
在goc里面,未找到此功能,是否有计划支持。
请最新进群二维码
We have multi service in one project, how do i use goc to cover multi service?
When build nonStandardLegacy project with goc, it will return an error like
http_cover_apis_auto_generated.go:20:2: cannot find package "gocbuildcd3524726b16" in any of: /usr/local/go/src/gocbuildcd3524726b16 (from $GOROOT) /Users/xxx/go/src/gocbuildcd3524726b16 (from $GOPATH)
If using go build
instead, the binary will build successful.
nonStandardLegacy project: project only use basic go packages without setting gopath.
Line 48 in 4b184c9
既然可以拿到覆盖率,那就肯定有覆盖行数和相应的总行数,这需要通过什么来获取呢
xxxxMacBook-Pro:~ xxxx$ go get -u github.com/qiniu/goc
xxx/src/github.com/hashicorp/go-retryablehttp/roundtripper.go:48:16: undefined: errors.Unwrap
xxxx/src/github.com/qiniu/goc/pkg/build/tmpfolder.go:86:5: undefined: errors.Is
现在是在 goc build 的时候指定 ip:port,能否支持在服务启动的时候通过服务发现,来获取 goc server 的 ip:port ? 场景是 goc server 的 ip 无法固定,同时服务的编译和启动是分开的,有一次编译,多次运行的场景。
When we use same goc_server for several different version of same code, we found that the goc profile cannot show which version it get. This makes me confused.
How service bind:
$ > cat _svrs_address.txt
MyProject/moduleA&http://ip1:port1
MyProject/moduleA&http://ip2:port2
How goc profile show:
...
MyProject/moduleA/main.go:32.13,37.16 4 2
MyProject/moduleA/main.go:37.16,39.3 1 0
...
We build several goc_sever for each version to solve it temporary.
Goc should have power to make it possible for code version control.
当有很多服务注册在goc server上面,服务被销毁后,获取覆盖率文件耗时很长,如果不手动清理,注册的服务会越来越多,耗时也越来越长。 有参数可以设置跟客服端的请求超时不
xxx_profile_listen_addr is a file to save service's last listen port, if same binary start in the same time, now it will save one port, the other one is missing.
Some files like unix socket
is not allowed to be copied. When project files contians these file, goc build .
will return an error. The file copy strategy needs optimize.
go install: cannot install cross-compiled binaries when GOBIN is set
"github.com/sparrc/go-ping"
I use goPing library in my projects . when i run the command "goc build ." error occurs but i can't understand.
mistake
./http_cover_apis_auto_generated.go:2135:89: undefined: cache_343664633233633838353763.GoCacheCover_0_34636232323162626631
./http_cover_apis_auto_generated.go:2137:88: undefined: cache_343664633233633838353763.GoCacheCover_1_34636232323162626631
./http_cover_apis_auto_generated.go:3978:17: undefined: cache_343664633233633838353763.GoCacheCover_0_34636232323162626631
./http_cover_apis_auto_generated.go:3980:17: undefined: cache_343664633233633838353763.GoCacheCover_1_34636232323162626631
FATA Fail to build: fail to execute: [/bin/bash -c go build -o /home/test .], err: exit status 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.