Skip to content

Commit

Permalink
Dockerize:
Browse files Browse the repository at this point in the history
1. Add the address to the test api objects
2. re order docker-compose so that it is in order of dependency
3. add a second endpoint to test against
4. fix node names registered in consul to have a more ture random number
5. small json formatting cleanup
  • Loading branch information
Kaley committed Aug 25, 2016
1 parent 6a58d25 commit 70262ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
7 changes: 4 additions & 3 deletions rackhd/cmd/utils/api/api.go
Expand Up @@ -78,7 +78,7 @@ func (e *Server) HandleServeArray(w http.ResponseWriter, r *http.Request) {
node := NodeObject{
Name: fmt.Sprintf("TESTNODE: %+v", rand.Intn(100)),
Thing1: "arrays for days",
Thing2: "moar things go here",
Thing2: e.Address,
Numbers: i,
}
nodes = append(nodes, node)
Expand All @@ -94,15 +94,16 @@ func (e *Server) HandleServeObject(w http.ResponseWriter, r *http.Request) {
object := NodeObject{
Name: name,
Thing1: "objects FTW",
Thing2: "moar things go here :)",
Thing2: e.Address,
Numbers: rand.Intn(90000),
}
json.NewEncoder(w).Encode(object)
}

// Register is...
func (e *Server) Register(datacenter, serviceName string) {
n := fmt.Sprintf("%d", rand.Int())
rGen := rand.New(rand.NewSource(time.Now().UnixNano()))
n := fmt.Sprintf("%d", rGen.Int())
err := e.Store.Register(&regStore.CatalogRegistration{
Node: n,
Address: e.Address,
Expand Down
80 changes: 41 additions & 39 deletions rackhd/docker-compose-rackhd.yaml
Expand Up @@ -19,6 +19,25 @@ services:
- "8600"
- "8600/udp"
command: "agent -config-dir /etc/consul.d/server.json -bootstrap"
consulclient:
image: "rackhd/consul:client"
container_name: "consulclient"
hostname: "consulclient"
ports:
- "8500:8500"
expose:
- "8300"
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "8500"
- "8500/udp"
- "8600"
- "8600/udp"
depends_on:
- consulserver
rackhd:
build:
context: .
Expand All @@ -28,68 +47,51 @@ services:
hostname: "rackhd"
links:
- consulclient
- endpoint1
- endpoint2
ports:
- "10001:10001"
expose:
- "10001"
- "10002"
- "8300"
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "10003"
- "8500"
- "8500/udp"
- "8600"
- "8600/udp"
command: "-proxy-address=http://0.0.0.0:10001 -backend-address=consulclient:8500 -service-name=RackHD-service:api:2.0:TEST -datacenter=dc-docker"
command: "-proxy-address=http://rackhd:10001 -backend-address=consulclient:8500 -service-name=RackHD-service:api:2.0:TEST -datacenter=dc-docker"
depends_on:
- consulclient
endpoint:
endpoint1:
build:
context: .
dockerfile: Dockerfile-endpoint
image: "rackhd/endpoint:latest"
container_name: "endpoint"
hostname: "endpoint"
container_name: "endpoint1"
hostname: "endpoint1"
links:
- consulclient
- rackhd
ports:
- "10002:10002"
expose:
- "10001"
- "10002"
- "8300"
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "8500"
- "8500/udp"
- "8600"
- "8600/udp"
command: "-endpoint-address=http://0.0.0.0:10002 -backend-address=consulclient:8500 -datacenter=dc-docker"
command: "-endpoint-address=http://endpoint1:10002 -backend-address=consulclient:8500 -datacenter=dc-docker"
depends_on:
- consulclient
consulclient:
image: "rackhd/consul:client"
container_name: "consulclient"
hostname: "consulclient"
endpoint2:
build:
context: .
dockerfile: Dockerfile-endpoint
image: "rackhd/endpoint:latest"
container_name: "endpoint2"
hostname: "endpoint2"
links:
- consulclient
ports:
- "8500:8500"
- "10003:10003"
expose:
- "8300"
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "10001"
- "10003"
- "8500"
- "8500/udp"
- "8600"
- "8600/udp"
command: "-endpoint-address=http://endpoint2:10003 -backend-address=consulclient:8500 -datacenter=dc-docker"
depends_on:
- consulserver
- consulclient
2 changes: 0 additions & 2 deletions rackhd/proxy/controller.go
Expand Up @@ -77,7 +77,6 @@ func (p *Server) GetResp(r *http.Request, addrs map[string]struct{}) (chan *Resp
r.URL.Scheme = "http"
fmt.Printf("url string %s\n", r.URL.String())
respGet, err := http.Get(r.URL.String())
fmt.Printf("%s\n", respGet.Status)
if err != nil {
errs <- fmt.Errorf("Could not send any HTTP Get requests: %s\n", err)
return
Expand All @@ -98,7 +97,6 @@ func (p *Server) GetResp(r *http.Request, addrs map[string]struct{}) (chan *Resp
// helper function to write to the ResponseWriter.
func (p *Server) RespCheck(w http.ResponseWriter, cr chan *Response) {
initialResp := <-cr
// if 1st byte is ! [, write iR and return
if initialResp.Body[0] != '[' {
w.Write(initialResp.Body)
return
Expand Down

0 comments on commit 70262ad

Please sign in to comment.