control: Implement service command 'stop,restart,status'. (#2883)

- stop - stops all the servers.
- restart - restart all the servers.
- status - prints status of storage info about the cluster.
This commit is contained in:
Harshavardhana
2016-10-09 23:03:10 -07:00
committed by GitHub
parent 57f75b1d9b
commit 3cfb23750a
21 changed files with 635 additions and 384 deletions

View File

@@ -24,7 +24,6 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"math/big"
@@ -158,6 +157,11 @@ func TestListenAndServePlain(t *testing.T) {
errc := make(chan error)
once := &sync.Once{}
// Initialize done channel specifically for each tests.
globalServiceDoneCh = make(chan struct{}, 1)
// Initialize signal channel specifically for each tests.
globalServiceSignalCh = make(chan serviceSignal, 1)
// Create ServerMux and when we receive a request we stop waiting
m := NewServerMux(addr, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "hello")
@@ -167,9 +171,6 @@ func TestListenAndServePlain(t *testing.T) {
// ListenAndServe in a goroutine, but we don't know when it's ready
go func() { errc <- m.ListenAndServe() }()
// Make sure we don't block by closing wait after a timeout
tf := time.AfterFunc(time.Millisecond*500, func() { errc <- errors.New("Unable to connect to server") })
wg := &sync.WaitGroup{}
wg.Add(1)
// Keep trying the server until it's accepting connections
@@ -184,7 +185,6 @@ func TestListenAndServePlain(t *testing.T) {
}
wg.Done()
tf.Stop() // Cancel the timeout since we made a successful request
}()
wg.Wait()
@@ -207,6 +207,9 @@ func TestListenAndServeTLS(t *testing.T) {
errc := make(chan error)
once := &sync.Once{}
// Initialize done channel specifically for each tests.
globalServiceDoneCh = make(chan struct{}, 1)
// Create ServerMux and when we receive a request we stop waiting
m := NewServerMux(addr, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "hello")
@@ -232,11 +235,8 @@ func TestListenAndServeTLS(t *testing.T) {
// ListenAndServe in a goroutine, but we don't know when it's ready
go func() { errc <- m.ListenAndServeTLS(certFile, keyFile) }()
// Make sure we don't block by closing wait after a timeout
tf := time.AfterFunc(time.Millisecond*500, func() { errc <- errors.New("Unable to connect to server") })
wg := &sync.WaitGroup{}
wg.Add(1)
// Keep trying the server until it's accepting connections
go func() {
tr := &http.Transport{
@@ -255,7 +255,6 @@ func TestListenAndServeTLS(t *testing.T) {
}
wg.Done()
tf.Stop() // Cancel the timeout since we made a successful request
}()
wg.Wait()