Ver Fonte

Change integration test "log" field to "instance"

Jakob Borg há 10 anos atrás
pai
commit
d4d391b34f

+ 8 - 8
test/filetype_test.go

@@ -101,10 +101,10 @@ func testFileTypeChange(t *testing.T) {
 	log.Println("Syncing...")
 
 	sender := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = sender.start()
 	if err != nil {
@@ -112,10 +112,10 @@ func testFileTypeChange(t *testing.T) {
 	}
 
 	receiver := syncthingProcess{ // id2
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = receiver.start()
 	if err != nil {

+ 12 - 12
test/http_test.go

@@ -41,9 +41,9 @@ var jsonEndpoints = []string{
 
 func TestGetIndex(t *testing.T) {
 	st := syncthingProcess{
-		argv: []string{"-home", "h2"},
-		port: 8082,
-		log:  "2.out",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		instance: "2",
 	}
 	err := st.start()
 	if err != nil {
@@ -84,9 +84,9 @@ func TestGetIndex(t *testing.T) {
 
 func TestGetIndexAuth(t *testing.T) {
 	st := syncthingProcess{
-		argv: []string{"-home", "h1"},
-		port: 8081,
-		log:  "1.out",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		instance: "1",
 	}
 	err := st.start()
 	if err != nil {
@@ -142,9 +142,9 @@ func TestGetIndexAuth(t *testing.T) {
 
 func TestGetJSON(t *testing.T) {
 	st := syncthingProcess{
-		argv: []string{"-home", "h2"},
-		port: 8082,
-		log:  "2.out",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		instance: "2",
 	}
 	err := st.start()
 	if err != nil {
@@ -174,9 +174,9 @@ func TestGetJSON(t *testing.T) {
 
 func TestPOSTWithoutCSRF(t *testing.T) {
 	st := syncthingProcess{
-		argv: []string{"-home", "h2"},
-		port: 8082,
-		log:  "2.out",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		instance: "2",
 	}
 	err := st.start()
 	if err != nil {

+ 4 - 4
test/httpstress_test.go

@@ -39,10 +39,10 @@ func TestStressHTTP(t *testing.T) {
 
 	log.Println("Starting up...")
 	sender := syncthingProcess{ // id1
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = sender.start()
 	if err != nil {

+ 4 - 4
test/ignore_test.go

@@ -36,10 +36,10 @@ func TestIgnores(t *testing.T) {
 	}
 
 	p := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = p.start()
 	if err != nil {

+ 8 - 8
test/manypeers_test.go

@@ -43,10 +43,10 @@ func TestManyPeers(t *testing.T) {
 	}
 
 	receiver := syncthingProcess{ // id2
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = receiver.start()
 	if err != nil {
@@ -90,10 +90,10 @@ func TestManyPeers(t *testing.T) {
 
 	log.Println("Starting up...")
 	sender := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = sender.start()
 	if err != nil {

+ 4 - 4
test/parallell_scan_test.go

@@ -46,10 +46,10 @@ func TestParallellScan(t *testing.T) {
 
 	log.Println("Starting up...")
 	st := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = st.start()
 	if err != nil {

+ 8 - 8
test/reconnect_test.go

@@ -54,10 +54,10 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
 
 	log.Println("Starting up...")
 	sender := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = sender.start()
 	if err != nil {
@@ -65,10 +65,10 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
 	}
 
 	receiver := syncthingProcess{ // id2
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = receiver.start()
 	if err != nil {

+ 8 - 8
test/symlink_test.go

@@ -177,10 +177,10 @@ func testSymlinks(t *testing.T) {
 	log.Println("Syncing...")
 
 	sender := syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err = sender.start()
 	if err != nil {
@@ -188,10 +188,10 @@ func testSymlinks(t *testing.T) {
 	}
 
 	receiver := syncthingProcess{ // id2
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = receiver.start()
 	if err != nil {

+ 12 - 12
test/sync_test.go

@@ -254,10 +254,10 @@ func scStartProcesses() ([]syncthingProcess, error) {
 	p := make([]syncthingProcess, 3)
 
 	p[0] = syncthingProcess{ // id1
-		log:    "1.out",
-		argv:   []string{"-home", "h1"},
-		port:   8081,
-		apiKey: apiKey,
+		instance: "1",
+		argv:     []string{"-home", "h1"},
+		port:     8081,
+		apiKey:   apiKey,
 	}
 	err := p[0].start()
 	if err != nil {
@@ -265,10 +265,10 @@ func scStartProcesses() ([]syncthingProcess, error) {
 	}
 
 	p[1] = syncthingProcess{ // id2
-		log:    "2.out",
-		argv:   []string{"-home", "h2"},
-		port:   8082,
-		apiKey: apiKey,
+		instance: "2",
+		argv:     []string{"-home", "h2"},
+		port:     8082,
+		apiKey:   apiKey,
 	}
 	err = p[1].start()
 	if err != nil {
@@ -277,10 +277,10 @@ func scStartProcesses() ([]syncthingProcess, error) {
 	}
 
 	p[2] = syncthingProcess{ // id3
-		log:    "3.out",
-		argv:   []string{"-home", "h3"},
-		port:   8083,
-		apiKey: apiKey,
+		instance: "3",
+		argv:     []string{"-home", "h3"},
+		port:     8083,
+		apiKey:   apiKey,
 	}
 	err = p[2].start()
 	if err != nil {

+ 3 - 3
test/syncthingprocess.go

@@ -37,7 +37,7 @@ var env = []string{
 }
 
 type syncthingProcess struct {
-	log       string
+	instance  string
 	argv      []string
 	port      int
 	apiKey    string
@@ -50,7 +50,7 @@ type syncthingProcess struct {
 
 func (p *syncthingProcess) start() error {
 	if p.logfd == nil {
-		logfd, err := os.Create(p.log)
+		logfd, err := os.Create(p.instance + ".out")
 		if err != nil {
 			return err
 		}
@@ -82,7 +82,7 @@ func (p *syncthingProcess) stop() error {
 	p.cmd.Process.Signal(os.Kill)
 	p.cmd.Wait()
 
-	fd, err := os.Open(p.log)
+	fd, err := os.Open(p.instance + ".out")
 	if err != nil {
 		return err
 	}