1
// Copyright Istio Authors
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
27
func TestStartStopEnabled(t *testing.T) {
28
server := startAndWaitForServer(t)
29
done := make(chan struct{}, 1)
36
case <-time.After(5 * time.Second):
37
t.Fatal("Timed out waiting for listeningTestProbe to be called")
41
func TestSignals(t *testing.T) {
42
c := make(chan os.Signal, 1)
43
signal.Notify(c, syscall.SIGUSR1)
44
server := startAndWaitForServer(t)
46
reloadURL := fmt.Sprintf("http://%v/signalj/SIGUSR1", server.Address())
47
resp, err := http.DefaultClient.Post(reloadURL, "text/plain", nil)
49
t.Fatalf("Run: %v", err)
51
if resp.StatusCode != http.StatusAccepted {
52
t.Fatalf("Got unexpected status code: %v", resp.StatusCode)
56
case <-time.After(5 * time.Second):
57
t.Fatal("Timed out waiting for SIGUSR1")
61
func startAndWaitForServer(t *testing.T) *Server {
62
ready := make(chan struct{}, 1)
63
listeningTestProbe = func() {
66
defer func() { listeningTestProbe = nil }()
68
// Start and wait for server
73
t.Fatalf("Failed to start server: %v", err)
77
case <-time.After(5 * time.Second):
78
t.Fatal("Timed out waiting for server start")