crawler_manager_go/crawler_manager_test.go

141 lines
2.2 KiB
Go
Raw Normal View History

2017-04-13 02:53:00 +00:00
package crawler_manager
import (
"testing"
//grpc1 "google.golang.org/grpc"
2017-04-14 02:29:55 +00:00
"os"
"os/exec"
"path/filepath"
"strings"
2017-04-13 02:53:00 +00:00
)
2017-04-14 02:29:55 +00:00
func TestManageCrawler(t *testing.T) {
ManageCrawler("/home/snoop/develop/path/go/src/loafle.com/overflow/crawler_manager_go/config/example.json")
}
2017-04-13 02:53:00 +00:00
func TestAdd(t *testing.T) {
CallAdd();
}
func TestCallInit(t *testing.T) {
2017-04-14 02:29:55 +00:00
//CallInit("")
2017-04-13 02:53:00 +00:00
}
func TestCallRemove(t *testing.T) {
CallRemove()
2017-04-14 02:29:55 +00:00
}
func TestPid(t *testing.T) {
pp, err := os.FindProcess(12314)
if err != nil{
t.Log("err : ", err)
}
t.Log(pp.Pid)
}
func TestPr(t *testing.T) {
//ps -aux | awk '{print $2}' | grep 15538
bytes, _ := exec.Command("ps","-aux", "awk", "{print $2}").Output()
t.Log(string(bytes))
}
func TestExe(t *testing.T) {
ps := exec.Command("ps", "-aux")
awk := exec.Command("awk", "{print $2}")
grep := exec.Command("grep", "22373")
awk.Stdin, _ = ps.StdoutPipe()
grep.Stdin,_ = awk.StdoutPipe()
ps.Start()
awk.Start()
byt, _ := grep.Output()
t.Log(len(byt))
}
func TestExeState(t *testing.T) {
ps := exec.Command("ps", "-aux")
awk := exec.Command("awk", "{print $2, $7}")
grep := exec.Command("grep", "22373")
awk2 := exec.Command("awk", "{print $2}")
awk.Stdin, _ = ps.StdoutPipe()
grep.Stdin,_ = awk.StdoutPipe()
awk2.Stdin,_ = grep.StdoutPipe()
ps.Start()
awk.Start()
grep.Start()
byt, _ := awk2.Output()
t.Log(len(byt))
t.Log(string(byt))
t.Log(len(strings.TrimSpace(string(byt))))
}
func TestPipe(t *testing.T) {
c1 := exec.Command("ls")
c2 := exec.Command("wc", "-l")
c2.Stdin, _ = c1.StdoutPipe()
//c2.Stdout = os.Stdout
_ = c1.Start()
aa, _ := c2.Output()
t.Log(string(aa))
}
func TestIsAlive(t *testing.T) {
IsAlive(15538)
}
func TestIsState(t *testing.T) {
b := IsState(225931)
t.Log(b)
}
func TestCom(t *testing.T) {
str:= "Z"
if str == "Z" {
t.Log("aaa")
}
}
func TestReadConfig(t *testing.T) {
c := ReadConfig("/home/snoop/develop/path/go/src/loafle.com/overflow/crawler_go/config/example.json")
t.Log(c)
}
func TestDir(t *testing.T) {
a := filepath.Dir("/home/snoop/develop/path/go/src/loafle.com/overflow/crawler_go/config/example.json")
t.Log(a)
}
func TestMyPid(t *testing.T) {
t.Log(os.Getpid())
}