-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheureka_test.go
More file actions
54 lines (50 loc) · 1.19 KB
/
eureka_test.go
File metadata and controls
54 lines (50 loc) · 1.19 KB
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
package eureka
import (
"fmt"
"strconv"
"testing"
"time"
)
func TestRegisterApp(t *testing.T) {
app := "GOAAA"
ip := "localhost"
port := 80
ins := Instance{
HostName: ip,
App: app,
Port: &Port{Port: port, Enable: "true"},
IPAddr: ip,
VipAddress: ip,
SecureVipAddress: ip,
HealthCheckUrl: "http://" + ip + ":" + strconv.Itoa(port) + "/health",
StatusPageUrl: "http://" + ip + ":" + strconv.Itoa(port) + "/status",
HomePageUrl: "http://" + ip + ":" + strconv.Itoa(port),
Status: "UP",
DataCenterInfo: &DataCenterInfo{
Name: "MyOwn",
Class: "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
},
}
serverUrls := []string{"http://192.168.1.19:1111/eureka"}
e, err := NewEureka(serverUrls, nil)
if err != nil {
t.Fatal(err)
}
err = e.RegisterInstane(&ins)
if err != nil {
t.Fatal(err)
}
e.SendHeartBeat(&ins, time.Second*20)
t.Log("register service success.")
for {
}
}
func TestGetApp(t *testing.T) {
serverUrls := []string{"http://192.168.1.19:1111/eureka"}
e, err := NewEureka(serverUrls, nil)
if err != nil {
t.Fatal(err)
}
urls := e.GetAppUrls("GOAAA")
fmt.Println(urls)
}