Skip to content

Commit

Permalink
Merge da3d15a into fc38b27
Browse files Browse the repository at this point in the history
  • Loading branch information
little-cui committed Jul 30, 2018
2 parents fc38b27 + da3d15a commit 20f99f9
Show file tree
Hide file tree
Showing 161 changed files with 5,395 additions and 1,868 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
bin/
output
**/*.coverprofile
**/coverage.out
**/coverage.txt

service-center.iml
.idea/
Expand Down
14 changes: 10 additions & 4 deletions etc/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,23 @@ registry_plugin = etcd
# manager_cluster = "127.0.0.1:2379"
manager_cluster = "127.0.0.1:2379"

#heartbeat that sync synchronizes client's endpoints with the known endpoints from the etcd membership,unit is second.
#<=0, use default 30s
# heartbeat that sync synchronizes client's endpoints with the known endpoints from
# the etcd membership, unit is second and value must greater then 1s, it is set
# default 30s if value less then 0
auto_sync_interval = 30s

# bootstrap time out of registry
connect_timeout = 10s

# request registry time out
registry_timeout = 30s

# indicate how many revision you want to keep in etcd
compact_index_delta = 100
compact_interval = 12h

# registry cache
# registry cache, if this option value set 0, service center can run
# in lower memory but no longer push the events to client.
enable_cache = 1

# pluggable cipher
Expand Down Expand Up @@ -112,7 +118,7 @@ ssl_mode = 0
ssl_verify_client = 1
# minimal tls protocol, [TLSv1.0, TLSv1.1, TLSv1.2]
ssl_protocols = TLSv1.2
ssl_ciphers = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256
ssl_ciphers = TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256

###################################################################
# log options
Expand Down
1 change: 1 addition & 0 deletions examples/service_center/ssl/cert_pwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changeme_123
13 changes: 13 additions & 0 deletions examples/service_center/ssl/server.cer
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICATCCAWoCCQDmvlmfua/ThTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE3MTIwNTA5MzA0NloXDTE4MTIwNTA5MzA0NlowRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtu5H
L8mlCL6n+BrQ71eJgJJJ427/DgovzHBqLTYuk/It987wNJFmTMgdWRXHujwe4bFt
G78d7OJteXcR7a68sIxWrytWeAwG88M62duS+DCUke1YuQ6hrfIADvE2ZgYEuVxz
5UxOTYYIjtSxCGKDuxmlvkJgO6lE0zIhtFxz1WcCAwEAATANBgkqhkiG9w0BAQsF
AAOBgQCq89sMPmhVS5+Mh+FvnNC9qOnsnqWhyAEc5XEmqtCTAe1XpO3CvPH7DdHz
Ss0FVqpBRqmxUR0sQo6t/S0kW7uwDgjm7nIy67wtTLOLclYW2Yw+d3ApwBVMhVBp
yhDpV90YZF7QM9uhdsEgLpbTqs4hvPB1pUWH6oXdtjnEkp6lFQ==
-----END CERTIFICATE-----
18 changes: 18 additions & 0 deletions examples/service_center/ssl/server_key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,22C64A026937643A490027AC7931D19A

FdV2dDDn5l767Ulha9IMxiwvyMu6BziFCjXbfsHB1aHdBfuFWV8uJ5lEYiWPWdj3
QIeK79QH8i6N0n2f1VfXtW7RJKS+6Gg9m1dttxGXY/6sEIkFJRPiWrNrzeHaXAoI
38CBZli2nvtZMLo8oBj/iuQ0qlkh00Mm2RW1SgJx2I6FJZLS8xb9kKUhPL/SlBYd
EboWXpKtubg5DhvQd8MKIaTJDf3L1Iqc7OMnLs64ONvfylYy39uv8yGsimHNItQh
ylHjUhmqOjCwnogO1Nh2wsjQCODRPEJzpu2fJ1lb2+xqwbTg3ygVwzLoK2ScXND4
DIo8YOa9jBCR9/Yg1IzqOIUD+UzQWhBqDejMHVXAGQb5e2AldLdFnGwx1Yz4FCIl
nULP8lcMDeYRK0sS4N5/I4nqfvlVPyj96Nj4F3D68Q8oQXl1rTSbKXmWILxIIlHm
tBf+NA16p9A9TegHr/qn3L3NRCxyY7gLwL+cNG2uZ9NqmxnSmWhL9UQgWYPeGr8Z
Z9nqqshfzIMoBjZ4QP1pifKhEvb0w2MpjKtiAR3hmwn8SJDp7CPTlb7nm5e5fjZb
nkzsTXYaJiYYiuEjiIsxJY/6ptWeYq9kqTT/3Hmy0MdkcqeDbcLwqo6jbAJxcPFf
C0SCJ+woIZJeHpZZjmH/qsZUKq2UEDsLqGruNMDzxarmme67lwPIDG2pZ90EIcNx
BR0ZU4owv9N+dO2sFsMNHae9X8mHWynUJ2V3ISxshvS3WJmq+YkeYTjYljeIZ28x
+UBhUrmikzx/CrIFd9irnkVhPIqJ+uUZEiMNEnT7VxCpHZHDU+ujweChUzaLkh0x
-----END RSA PRIVATE KEY-----
13 changes: 13 additions & 0 deletions examples/service_center/ssl/trust.cer
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICATCCAWoCCQCu7pAj81WabjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE3MTIwNTA5MTMzNVoXDTE4MTIwNTA5MTMzNVowRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyDpT
In6x3H0HEGOXzJMByOnvzD4rL0B4wyE9K2Nng0Ev0pS0dlPQK67fZJ6e2KDcA72d
dSps61YQ6tWnBbssCZat0qI2g3Kh4wKgEoCv/0Wm9J+c9gHO9VXyRd91FkJNFDB4
Lsh4EF4kMVsdLfvP98LkQQAfjg621Yqa1bEu5RUCAwEAATANBgkqhkiG9w0BAQsF
AAOBgQCbURtlhZMNUN8W2EQJVqgEbZmtNriI1VpKvfU4b8d05PwaoL3qV8tx6p5/
2p/+diRH8XWkPMm0Ix+c7752ebWSVb8WoQL40ZBd4PIuy6RlS7/45VeMUk7LvxBG
iPXnB72OzQmBiPhVNiINVumQWJ62NPlbYaJsG/WsZdaWYMDeww==
-----END CERTIFICATE-----
5 changes: 3 additions & 2 deletions frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/astaxie/beego"
"net"
"net/url"
"strconv"
)

type Config struct {
Expand All @@ -42,8 +43,8 @@ func main() {
flag.Parse()

cfg := Config{}
cfg.scAddr = fmt.Sprintf("http://%s/", net.JoinHostPort(url.PathEscape(scIp), fmt.Sprint(scPort)))
cfg.frontendAddr = net.JoinHostPort(frontendIp, fmt.Sprint(*port))
cfg.scAddr = fmt.Sprintf("http://%s/", net.JoinHostPort(url.PathEscape(scIp), strconv.Itoa(scPort)))
cfg.frontendAddr = net.JoinHostPort(frontendIp, strconv.Itoa(*port))

// run frontend web server
Serve(cfg)
Expand Down
40 changes: 40 additions & 0 deletions integration/admin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package integrationtest_test

import (
. "github.com/apache/incubator-servicecomb-service-center/integration"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/widuu/gojson"
"io/ioutil"
"net/http"
)

var _ = Describe("Admin Api Test", func() {
It("dump", func() {
req, _ := http.NewRequest(GET, SCURL+DUMP, nil)
req.Header.Set("X-Domain-Name", "default")
resp, err := scclient.Do(req)
respbody, _ := ioutil.ReadAll(resp.Body)
_, d := gojson.Json(string(respbody)).Getpath("cache", "services").ToArray()
Expect(err).To(BeNil())
Expect(resp.StatusCode).To(Equal(http.StatusOK))
Expect(len(d)).ToNot(Equal(0))
defer resp.Body.Close()
})
})
3 changes: 3 additions & 0 deletions integration/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ var UPDATETAG = "/v4/default/registry/microservices/:serviceId/tags/:key"
var GETTAGS = "/v4/default/registry/microservices/:serviceId/tags"
var DELETETAG = "/v4/default/registry/microservices/:serviceId/tags/:key"

//Admin API's
var DUMP = "/v4/default/admin/dump"

// HTTP METHODS
var GET = "GET"
var POST = "POST"
Expand Down
6 changes: 4 additions & 2 deletions integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ var _ = Describe("MicroService Api Test", func() {

By("Discover MicroService Instance API", func() {
It("Find Micro-service Info by AppID", func() {
req, _ := http.NewRequest(GET, SCURL+FINDINSTANCE+"?noCache=1&appId="+serviceAppId+"&serviceName="+serviceName+"&version="+serviceVersion, nil)
req, _ := http.NewRequest(GET, SCURL+FINDINSTANCE+"?appId="+serviceAppId+"&serviceName="+serviceName+"&version="+serviceVersion, nil)
req.Header.Set("X-Domain-Name", "default")
req.Header.Set("X-ConsumerId", serviceId)
resp, _ := scclient.Do(req)
Expand Down Expand Up @@ -330,7 +330,7 @@ var _ = Describe("MicroService Api Test", func() {
})

It("Find Micro-Service Instance with rev", func() {
req, _ := http.NewRequest(GET, SCURL+FINDINSTANCE+"?noCache=1&appId="+serviceAppId+"&serviceName="+serviceName+"&version="+serviceVersion, nil)
req, _ := http.NewRequest(GET, SCURL+FINDINSTANCE+"?appId="+serviceAppId+"&serviceName="+serviceName+"&version="+serviceVersion, nil)
req.Header.Set("X-Domain-Name", "default")
req.Header.Set("X-ConsumerId", serviceId)
resp, _ := scclient.Do(req)
Expand All @@ -349,6 +349,7 @@ var _ = Describe("MicroService Api Test", func() {
Expect(rev).NotTo(BeEmpty())
})
})

By("Update Micro-Service Instance Information API's", func() {
It("Update Micro-Service Instance Properties", func() {
propertiesInstance := map[string]interface{}{
Expand Down Expand Up @@ -473,6 +474,7 @@ var _ = Describe("MicroService Api Test", func() {
}
})
})

By("Micro-Service Instance heartbeat API", func() {
It("Send HeartBeat for micro-service instance", func() {
url := strings.Replace(INSTANCEHEARTBEAT, ":serviceId", serviceId, 1)
Expand Down
53 changes: 38 additions & 15 deletions integration/microservices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,21 @@ var _ = Describe("MicroService Api Test", func() {
// Validate the dependency creation
Expect(resp.StatusCode).To(Equal(http.StatusOK))

<-time.After(time.Second)
// add new dependency
dependency["providers"] = []interface{}{consumer}
body, _ = json.Marshal(bodyParams)
bodyBuf = bytes.NewReader(body)
req, _ = http.NewRequest(POST, SCURL+CREATEDEPENDENCIES, bodyBuf)
req.Header.Set("X-Domain-Name", "default")
resp, err = scclient.Do(req)
Expect(err).To(BeNil())
defer resp.Body.Close()

// Validate the dependency creation
Expect(resp.StatusCode).To(Equal(http.StatusOK))

//Get Provider by ConsumerID
<-time.After(time.Second)
url := strings.Replace(GETCONPRODEPENDENCY, ":consumerId", consumerServiceID, 1)
req, _ = http.NewRequest(GET, SCURL+url, nil)
req.Header.Set("X-Domain-Name", "default")
Expand All @@ -432,7 +444,6 @@ var _ = Describe("MicroService Api Test", func() {
Expect(foundMicroService).To(Equal(true))

//Get Consumer by ProviderID

url = strings.Replace(GETPROCONDEPENDENCY, ":providerId", serviceId, 1)
req, _ = http.NewRequest(GET, SCURL+url, nil)
req.Header.Set("X-Domain-Name", "default")
Expand All @@ -451,10 +462,30 @@ var _ = Describe("MicroService Api Test", func() {
}
Expect(foundMicroService).To(Equal(true))

providersArray = []interface{}{consumer}
//Get new dependency by ConsumerID
url = strings.Replace(GETCONPRODEPENDENCY, ":consumerId", consumerServiceID, 1)
req, _ = http.NewRequest(GET, SCURL+url, nil)
req.Header.Set("X-Domain-Name", "default")
resp, _ = scclient.Do(req)
respbody, _ = ioutil.ReadAll(resp.Body)
Expect(resp.StatusCode).To(Equal(http.StatusOK))
servicesStruct = map[string][]map[string]interface{}{}

json.Unmarshal(respbody, &servicesStruct)
foundMicroService = false
for _, services := range servicesStruct["providers"] {
if services["serviceName"] == consumerAppName {
foundMicroService = true
break
}
}
Expect(foundMicroService).To(Equal(true))

// override the dependency
dependency["providers"] = []interface{}{}
body, _ = json.Marshal(bodyParams)
bodyBuf = bytes.NewReader(body)
req, _ = http.NewRequest(POST, SCURL+CREATEDEPENDENCIES, bodyBuf)
req, _ = http.NewRequest(UPDATE, SCURL+CREATEDEPENDENCIES, bodyBuf)
req.Header.Set("X-Domain-Name", "default")
resp, err = scclient.Do(req)
Expect(err).To(BeNil())
Expand All @@ -463,24 +494,17 @@ var _ = Describe("MicroService Api Test", func() {
// Validate the dependency creation
Expect(resp.StatusCode).To(Equal(http.StatusOK))

//Get Provider by ConsumerID
//Get Provider by ConsumerID again
<-time.After(time.Second)
url = strings.Replace(GETCONPRODEPENDENCY, ":consumerId", consumerServiceID, 1)
req, _ = http.NewRequest(GET, SCURL+url, nil)
req.Header.Set("X-Domain-Name", "default")
resp, _ = scclient.Do(req)
respbody, _ = ioutil.ReadAll(resp.Body)
Expect(resp.StatusCode).To(Equal(http.StatusOK))
servicesStruct = map[string][]map[string]interface{}{}

json.Unmarshal(respbody, &servicesStruct)
foundMicroService = false
for _, services := range servicesStruct["providers"] {
if services["serviceName"] == serviceName {
foundMicroService = true
break
}
}
Expect(foundMicroService).To(Equal(true))
Expect(len(servicesStruct["providers"])).To(Equal(0))

//Delete Consumer and Provider
url = strings.Replace(UNREGISTERMICROSERVICE, ":serviceId", consumerServiceID, 1)
Expand All @@ -498,7 +522,6 @@ var _ = Describe("MicroService Api Test", func() {
})

It("Invalid scenario for GET Providers and Consumers", func() {

//Get Provider by ConsumerID
url := strings.Replace(GETCONPRODEPENDENCY, ":consumerId", "wrongID", 1)
req, _ := http.NewRequest(GET, SCURL+url, nil)
Expand Down

0 comments on commit 20f99f9

Please sign in to comment.