cluster_config_test.go 835 B

1234567891011121314151617181920212223242526272829
  1. package test
  2. import (
  3. "bytes"
  4. "os"
  5. "testing"
  6. "time"
  7. "github.com/coreos/etcd/tests"
  8. "github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
  9. )
  10. // Ensure that the cluster configuration can be updated.
  11. func TestClusterConfig(t *testing.T) {
  12. _, etcds, err := CreateCluster(3, &os.ProcAttr{Files: []*os.File{nil, os.Stdout, os.Stderr}}, false)
  13. assert.NoError(t, err)
  14. defer DestroyCluster(etcds)
  15. resp, _ := tests.Put("http://localhost:7001/config", "application/json", bytes.NewBufferString(`{"activeSize":3, "promoteDelay":60}`))
  16. assert.Equal(t, resp.StatusCode, 200)
  17. time.Sleep(1 * time.Second)
  18. resp, _ = tests.Get("http://localhost:7002/config")
  19. body := tests.ReadBodyJSON(resp)
  20. assert.Equal(t, resp.StatusCode, 200)
  21. assert.Equal(t, body["activeSize"], 3)
  22. assert.Equal(t, body["promoteDelay"], 60)
  23. }