Merge pull request #499 from bilibili/lich/support_windows

lich support windows,奥里给!
pull/524/head
Terry.Mao 5 years ago committed by GitHub
commit 7c946dc919
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      pkg/testing/lich/composer.go
  2. 13
      tool/kratos/tool_index.go

@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"time"
"github.com/bilibili/kratos/pkg/log"
@ -24,6 +25,7 @@ var (
func init() {
flag.StringVar(&yamlPath, "f", "docker-compose.yaml", "composer yaml path.")
flag.IntVar(&retry, "retry", 5, "number of retries on network failure.")
flag.BoolVar(&noDown, "nodown", false, "containers are not recycled.")
}
@ -74,10 +76,13 @@ func getServices() (output []byte, err error) {
if output, err = runCompose("config", "--services"); err != nil {
return
}
var eol = []byte("\n")
if output = bytes.TrimSpace(output); runtime.GOOS == "windows" {
eol = []byte("\r\n")
}
services = make(map[string]*Container)
output = bytes.TrimSpace(output)
for _, svr := range bytes.Split(output, []byte("\n")) {
if output, err = runCompose("ps", "-a", "-q", string(svr)); err != nil {
for _, svr := range bytes.Split(output, eol) {
if output, err = runCompose("ps", "-q", string(svr)); err != nil {
return
}
var (
@ -105,18 +110,17 @@ func getServices() (output []byte, err error) {
func checkServices() (output []byte, err error) {
defer func() {
if err != nil && retry < 4 {
retry++
if err != nil && retry > 0 {
retry--
getServices()
time.Sleep(time.Second * 5)
output, err = checkServices()
return
}
retry = 0
}()
for svr, c := range services {
if err = c.Healthcheck(); err != nil {
log.Error("healthcheck(%s) error(%v) retrying %d times...", svr, err, 5-retry)
log.Error("healthcheck(%s) error(%v) retrying %d times...", svr, err, retry)
return
}
// TODO About container check and more...

@ -66,12 +66,21 @@ var toolIndexs = []*Tool{
Hidden: true,
Requirements: []string{"wire"},
},
{
Name: "testgen",
Alias: "testgen",
BuildTime: time.Date(2020, 1, 20, 22, 33, 0, 0, time.Local),
Install: "go get -u github.com/bilibili/kratos/tool/testgen",
Summary: "测试代码生成",
Platform: []string{"darwin", "linux", "windows"},
Author: "kratos",
},
{
Name: "testcli",
Alias: "testcli",
BuildTime: time.Date(2019, 9, 9, 0, 0, 0, 0, time.Local),
BuildTime: time.Date(2020, 1, 20, 22, 33, 0, 0, time.Local),
Install: "go get -u github.com/bilibili/kratos/tool/testcli",
Summary: "测试代码生成",
Summary: "测试代码运行",
Platform: []string{"darwin", "linux", "windows"},
Author: "kratos",
},

Loading…
Cancel
Save