forked from micro/micro
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpc_test.go
executable file
·90 lines (80 loc) · 2.06 KB
/
rpc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//go:build integration
// +build integration
package test
import (
"errors"
"fmt"
"strings"
"testing"
"time"
)
func Testroutes(t *testing.T) {
TrySuite(t, testroutes, retryCount)
}
func testroutes(t *T) {
t.Parallel()
serv := NewServer(t, WithLogin())
defer serv.Close()
if err := serv.Run(); err != nil {
return
}
cmd := serv.Command()
outp, err := cmd.Exec("run", "--image", "localhost:5000/cells:v3", "./services/test/routes/routes-server")
if err != nil {
t.Fatalf("micro run failure, output: %v", string(outp))
return
}
if err := Try("Find routes-server in runtime", t, func() ([]byte, error) {
outp, err := cmd.Exec("status")
if err != nil {
return outp, err
}
if !statusRunning("routes-server", "latest", outp) {
return outp, errors.New("Can't find routes-server in runtime")
}
return nil, nil
}, 120*time.Second); err != nil {
return
}
if err := Try("Find routes service in registry", t, func() ([]byte, error) {
outp, err := cmd.Exec("services")
if err != nil {
return outp, err
}
if !strings.Contains(string(outp), "routes") {
return outp, errors.New("Can't find routes service in registry")
}
return nil, nil
}, 120*time.Second); err != nil {
return
}
outp, err = cmd.Exec("run", "--image", "localhost:5000/cells:v3", "./services/test/routes/routes-client")
if err != nil {
t.Fatalf("micro run failure, output: %v", string(outp))
return
}
if err := Try("Find routes-client in runtime", t, func() ([]byte, error) {
outp, err := cmd.Exec("status")
if err != nil {
return outp, err
}
if !statusRunning("routes-client", "latest", outp) {
return outp, errors.New("Can't find routes-client in runtime")
}
return nil, nil
}, 60*time.Second); err != nil {
return
}
if err := Try("Check logs", t, func() ([]byte, error) {
outp, err := cmd.Exec("logs", "routes-client")
if err != nil {
return nil, err
}
if !strings.Contains(string(outp), "Client completed ok") {
return outp, fmt.Errorf("Client did not complete ok")
}
return nil, nil
}, 120*time.Second); err != nil {
return
}
}