Welcome to mirror list, hosted at ThFree Co, Russian Federation.

health_test.go « rubyserver « gitaly « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c074435e83d72047a89dbcc43935ba4363280011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package rubyserver

import (
	"testing"
	"time"

	"github.com/stretchr/testify/require"
)

func TestPingSuccess(t *testing.T) {
	s := &Server{}
	require.NoError(t, s.Start())
	defer s.Stop()

	require.True(t, len(s.workers) > 0, "expected at least one worker in server")
	w := s.workers[0]

	var pingErr error
	for start := time.Now(); time.Since(start) < ConnectTimeout; time.Sleep(100 * time.Millisecond) {
		pingErr = ping(w.address)
		if pingErr == nil {
			break
		}
	}

	require.NoError(t, pingErr, "health check should pass")
}

func TestPingFail(t *testing.T) {
	require.Error(t, ping("fake address"), "health check should fail")
}