-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathintegration_test.go
66 lines (50 loc) · 1.4 KB
/
integration_test.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//go:build integration
// +build integration
// Integration test used for testing s3proxy code of this repository
// with the following running backends : minio and rsyslog
package test
import (
"net"
"net/http"
"testing"
"github.com/gin-gonic/gin"
"github.com/mirakl/s3proxy/backend"
"github.com/mirakl/s3proxy/logger"
"github.com/mirakl/s3proxy/router"
"github.com/mirakl/s3proxy/s3proxytest"
logging "github.com/op/go-logging"
)
var (
log = logging.MustGetLogger("s3proxy")
s3proxyHost = ""
)
func setupIntegration(t *testing.T) {
// Let the os select an available port for the s3proxy
listener, err := net.Listen("tcp", ":0")
if err != nil {
log.Fatal(err)
}
s3proxyHost = listener.Addr().String()
err = logger.AddRsyslogBackend("rsyslog:514")
if err != nil {
log.Fatal(err)
}
s3Backend, err := backend.NewS3Backend(s3proxytest.MinioBackendConfig)
if err != nil {
log.Fatal(err)
}
router := router.NewGinEngine(gin.ReleaseMode, "9.9.9", s3proxytest.URLExpiration, s3proxytest.ServerAPIKey, s3Backend)
go func() {
log.Debug("Listening on port : %v", listener.Addr())
// serve connections
if err := http.Serve(listener, router); err != nil {
log.Fatal(err)
}
}()
s3proxytest.WaitForRessources(t, s3proxyHost)
}
func TestIntegration(t *testing.T) {
defer s3proxytest.CatchPanic()
setupIntegration(t)
s3proxytest.RunSimpleScenarioForS3proxy(t, s3proxyHost)
}