-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver_test.go
70 lines (55 loc) · 2.09 KB
/
driver_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
package driver
// import (
// "fmt"
// "github.com/nacos-group/nacos-sdk-go/common/logger"
// "github.com/stretchr/testify/assert"
// "testing"
// )
// func TestNacosDriver_RegisterHttpService(t *testing.T) {
// target := "1.14.127.29:8848"
// endpoint := "127.0.0.1:36789"
// options := make(map[string]string)
// options["username"] = "nacos"
// options["password"] = "nacos"
// driver := &nacosDriver{}
// err := driver.RegisterHttpService(target, endpoint, options)
// assert.Nil(t, err)
// //time.Sleep(3600 * time.Second)
// }
// func TestNacosDriver_SelectOneHealthyInstancer(t *testing.T) {
// target := "127.0.0.1:8848"
// endpoint := "127.0.0.1:36789"
// options := make(map[string]string)
// options["username"] = "nacos"
// options["password"] = "nacos"
// driver := &nacosDriver{}
// err := driver.RegisterHttpService(target, endpoint, options)
// assert.Nil(t, err)
// instance, err := driver.SelectOneHealthyInstance("dtmService", "", nil)
// assert.Nil(t, err)
// logger.Infof("%v", instance)
// }
// func TestNacosDriver_ResolveHttpService(t *testing.T) {
// target := "127.0.0.1:8848"
// endpoint := "127.0.0.1:36789"
// options := make(map[string]string)
// options["username"] = "nacos"
// options["password"] = "nacos"
// options["namespaceId"] = "c3dc917d-906a-429d-90a9-85012b41014e"
// driver := &nacosDriver{}
// err := driver.RegisterHttpService(target, endpoint, options)
// if err != nil {
// logger.Errorf("exception: %v", err)
// t.Failed()
// }
// originalUrl := "http://dtmcli-spring-boot-starter-sample/feignTest?clusters=[\"DEFAULT\"]&groupName=DEFAULT_GROUP&a=1"
// realUrl := driver.ResolveHttpService(originalUrl)
// assert.Equal(t, realUrl, "http://192.168.101.9:8888/feignTest?a=1")
// fmt.Println(realUrl)
// originalUrl = "http://192.168.101.9:8888/feignTest?a=1"
// realUrl = driver.ResolveHttpService(originalUrl)
// assert.Equal(t, realUrl, originalUrl)
// originalUrl = "http://dtmcli-spring-boot-starter-sample/feignTest?groupName=abcd"
// realUrl = driver.ResolveHttpService(originalUrl)
// assert.Equal(t, realUrl, originalUrl)
// }