mirror of
				https://github.com/go-micro/go-micro.git
				synced 2025-10-30 23:27:41 +02:00 
			
		
		
		
	dont display t.Log/t.Logf as errors in github actions (#1508)
* fix tests and github action annotations Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| func TestCertMagic(t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) != 0 { | ||||
| 		t.Skip("Travis doesn't let us bind :443") | ||||
| 		t.Skip() | ||||
| 	} | ||||
| 	l, err := NewProvider().Listen() | ||||
| 	if err != nil { | ||||
| @@ -52,6 +52,10 @@ func TestCertMagic(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestStorageImplementation(t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) != 0 { | ||||
| 		t.Skip() | ||||
| 	} | ||||
|  | ||||
| 	apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") | ||||
| 	kvID := os.Getenv("KV_NAMESPACE_ID") | ||||
| 	if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { | ||||
| @@ -189,6 +193,10 @@ func TestStorageImplementation(t *testing.T) { | ||||
|  | ||||
| // Full test with a real zone, with  against LE staging | ||||
| func TestE2e(t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) != 0 { | ||||
| 		t.Skip() | ||||
| 	} | ||||
|  | ||||
| 	apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") | ||||
| 	kvID := os.Getenv("KV_NAMESPACE_ID") | ||||
| 	if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package selector | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/micro/go-micro/v2/registry/memory" | ||||
| @@ -25,5 +26,7 @@ func TestRegistrySelector(t *testing.T) { | ||||
| 		counts[node.Id]++ | ||||
| 	} | ||||
|  | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("Selector Counts %v", counts) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package selector | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/micro/go-micro/v2/registry" | ||||
| @@ -50,6 +51,8 @@ func TestStrategies(t *testing.T) { | ||||
| 			counts[node.Id]++ | ||||
| 		} | ||||
|  | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("%s: %+v\n", name, counts) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -59,8 +59,8 @@ func TestFile(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Error(err) | ||||
| 	} | ||||
| 	t.Logf("%+v", c) | ||||
| 	if string(c.Data) != string(data) { | ||||
| 		t.Logf("%+v", c) | ||||
| 		t.Error("data from file does not match") | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package memory | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| @@ -205,7 +206,9 @@ func TestMemoryRegistryTTLConcurrent(t *testing.T) { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("test will wait %v, then check TTL timeouts", waitTime) | ||||
| 	} | ||||
|  | ||||
| 	errChan := make(chan error, concurrency) | ||||
| 	syncChan := make(chan struct{}) | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package registry | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| @@ -32,8 +33,10 @@ func TestRemove(t *testing.T) { | ||||
| 	if i := len(servs); i > 0 { | ||||
| 		t.Errorf("Expected 0 nodes, got %d: %+v", i, servs) | ||||
| 	} | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("Services %+v", servs) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRemoveNodes(t *testing.T) { | ||||
| 	services := []*Service{ | ||||
| @@ -67,5 +70,7 @@ func TestRemoveNodes(t *testing.T) { | ||||
| 	if i := len(nodes); i != 1 { | ||||
| 		t.Errorf("Expected only 1 node, got %d: %+v", i, nodes) | ||||
| 	} | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("Nodes %+v", nodes) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package router | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"sync" | ||||
| 	"testing" | ||||
| 	"time" | ||||
| @@ -29,8 +30,10 @@ func TestRouterStartStop(t *testing.T) { | ||||
| 	if err := r.Stop(); err != nil { | ||||
| 		t.Errorf("failed to stop router: %v", err) | ||||
| 	} | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("TestRouterStartStop STOPPED") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRouterAdvertise(t *testing.T) { | ||||
| 	r := routerTestSetup() | ||||
| @@ -49,7 +52,9 @@ func TestRouterAdvertise(t *testing.T) { | ||||
|  | ||||
| 	// receive announce event | ||||
| 	ann := <-ch | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("received announce advert: %v", ann) | ||||
| 	} | ||||
|  | ||||
| 	// Generate random unique routes | ||||
| 	nrRoutes := 5 | ||||
| @@ -81,9 +86,13 @@ func TestRouterAdvertise(t *testing.T) { | ||||
| 		wg.Done() | ||||
| 		defer close(createDone) | ||||
| 		for _, route := range routes { | ||||
| 			if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 				t.Logf("Creating route %v", route) | ||||
| 			} | ||||
| 			if err := r.Table().Create(route); err != nil { | ||||
| 				if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 					t.Logf("Failed to create route: %v", err) | ||||
| 				} | ||||
| 				errChan <- err | ||||
| 				return | ||||
| 			} | ||||
| @@ -105,7 +114,9 @@ func TestRouterAdvertise(t *testing.T) { | ||||
| 				t.Errorf("failed advertising events: %v", advertErr) | ||||
| 			default: | ||||
| 				// do nothing for now | ||||
| 				if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 					t.Logf("Router advert received: %v", advert) | ||||
| 				} | ||||
| 				adverts += len(advert.Events) | ||||
| 			} | ||||
| 			return | ||||
|   | ||||
| @@ -11,6 +11,10 @@ import ( | ||||
| ) | ||||
|  | ||||
| func TestCloudflare(t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) != 0 { | ||||
| 		t.Skip() | ||||
| 	} | ||||
|  | ||||
| 	apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") | ||||
| 	kvID := os.Getenv("KV_NAMESPACE_ID") | ||||
| 	if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { | ||||
| @@ -31,8 +35,10 @@ func TestCloudflare(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("List: %s\n", err.Error()) | ||||
| 	} else { | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Log("Listed " + strconv.Itoa(len(records)) + " records") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	err = wkv.Write(&store.Record{ | ||||
| 		Key:   randomK, | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package cockroach | ||||
| import ( | ||||
| 	"database/sql" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| @@ -11,6 +12,10 @@ import ( | ||||
| ) | ||||
|  | ||||
| func TestSQL(t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) != 0 { | ||||
| 		t.Skip() | ||||
| 	} | ||||
|  | ||||
| 	connection := fmt.Sprintf( | ||||
| 		"host=%s port=%d user=%s sslmode=disable dbname=%s", | ||||
| 		"localhost", | ||||
| @@ -23,7 +28,7 @@ func TestSQL(t *testing.T) { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if err := db.Ping(); err != nil { | ||||
| 		t.Skip(err) | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	db.Close() | ||||
|  | ||||
|   | ||||
| @@ -53,8 +53,9 @@ func TestFileStoreDatabaseTable(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func fileTest(s store.Store, t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("Options %s %v\n", s.String(), s.Options()) | ||||
|  | ||||
| 	} | ||||
| 	// Read and Write an expiring Record | ||||
| 	if err := s.Write(&store.Record{ | ||||
| 		Key:    "Hello", | ||||
| @@ -109,7 +110,7 @@ func fileTest(s store.Store, t *testing.T) { | ||||
| 	} else { | ||||
| 		if len(results) != 2 { | ||||
| 			t.Errorf("Expected 2 items, got %d", len(results)) | ||||
| 			t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 			//t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -120,7 +121,7 @@ func fileTest(s store.Store, t *testing.T) { | ||||
| 		t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", spew.Sdump(results), err) | ||||
| 	} else if len(results) != 1 { | ||||
| 		t.Errorf("Expected 1 item, got %d", len(results)) | ||||
| 		t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 		//t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 	} | ||||
|  | ||||
| 	if err := s.Delete("foo"); err != nil { | ||||
| @@ -163,7 +164,7 @@ func fileTest(s store.Store, t *testing.T) { | ||||
| 	} else { | ||||
| 		if len(results) != 3 { | ||||
| 			t.Errorf("Expected 3 items, got %d", len(results)) | ||||
| 			t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 			//t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| @@ -173,7 +174,7 @@ func fileTest(s store.Store, t *testing.T) { | ||||
| 	} else { | ||||
| 		if len(results) != 2 { | ||||
| 			t.Errorf("Expected 2 items, got %d", len(results)) | ||||
| 			t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 			//t.Logf("Table test: %v\n", spew.Sdump(results)) | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| @@ -183,7 +184,7 @@ func fileTest(s store.Store, t *testing.T) { | ||||
| 	} else { | ||||
| 		if len(results) != 1 { | ||||
| 			t.Errorf("Expected 1 item, got %d", len(results)) | ||||
| 			t.Logf("Table test: %# v\n", spew.Sdump(results)) | ||||
| 			//	t.Logf("Table test: %# v\n", spew.Sdump(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	if err := s.Delete("foo"); err != nil { | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package memory | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| @@ -42,7 +43,9 @@ func TestMemoryNamespacePrefix(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func basictest(s store.Store, t *testing.T) { | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		t.Logf("Testing store %s, with options %# v\n", s.String(), pretty.Formatter(s.Options())) | ||||
| 	} | ||||
| 	// Read and Write an expiring Record | ||||
| 	if err := s.Write(&store.Record{ | ||||
| 		Key:    "Hello", | ||||
| @@ -97,8 +100,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 3 { | ||||
| 			t.Errorf("Expected 3 items, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	time.Sleep(time.Millisecond * 100) | ||||
| 	if results, err := s.Read("foo", store.ReadPrefix()); err != nil { | ||||
| 		t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) | ||||
| @@ -106,8 +111,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 2 { | ||||
| 			t.Errorf("Expected 2 items, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	time.Sleep(time.Millisecond * 100) | ||||
| 	if results, err := s.Read("foo", store.ReadPrefix()); err != nil { | ||||
| 		t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) | ||||
| @@ -115,8 +122,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 1 { | ||||
| 			t.Errorf("Expected 1 item, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %# v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	if err := s.Delete("foo", func(d *store.DeleteOptions) {}); err != nil { | ||||
| 		t.Errorf("Delete failed (%v)", err) | ||||
| 	} | ||||
| @@ -156,8 +165,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 3 { | ||||
| 			t.Errorf("Expected 3 items, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	time.Sleep(time.Millisecond * 100) | ||||
| 	if results, err := s.Read("foo", store.ReadSuffix()); err != nil { | ||||
| 		t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) | ||||
| @@ -165,8 +176,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 2 { | ||||
| 			t.Errorf("Expected 2 items, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	time.Sleep(time.Millisecond * 100) | ||||
| 	if results, err := s.Read("foo", store.ReadSuffix()); err != nil { | ||||
| 		t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) | ||||
| @@ -174,8 +187,10 @@ func basictest(s store.Store, t *testing.T) { | ||||
| 		if len(results) != 1 { | ||||
| 			t.Errorf("Expected 1 item, got %d", len(results)) | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Prefix test: %# v\n", pretty.Formatter(results)) | ||||
| 		} | ||||
| 	} | ||||
| 	if err := s.Delete("foo"); err != nil { | ||||
| 		t.Errorf("Delete failed (%v)", err) | ||||
| 	} | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package memory | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/micro/go-micro/v2/transport" | ||||
| @@ -24,7 +25,9 @@ func TestMemoryTransport(t *testing.T) { | ||||
| 				if err := sock.Recv(&m); err != nil { | ||||
| 					return | ||||
| 				} | ||||
| 				if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 					t.Logf("Server Received %s", string(m.Body)) | ||||
| 				} | ||||
| 				if err := sock.Send(&transport.Message{ | ||||
| 					Body: []byte(`pong`), | ||||
| 				}); err != nil { | ||||
| @@ -54,8 +57,10 @@ func TestMemoryTransport(t *testing.T) { | ||||
| 		if err := c.Recv(&m); err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("Client Received %s", string(m.Body)) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package tunnel | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"sync" | ||||
| 	"testing" | ||||
| 	"time" | ||||
| @@ -288,6 +289,8 @@ func TestTunnelRTTRate(t *testing.T) { | ||||
| 	// wait until done | ||||
| 	wg.Wait() | ||||
|  | ||||
| 	if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 		// only needed for debug | ||||
| 		for _, link := range tunA.Links() { | ||||
| 			t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate()) | ||||
| 		} | ||||
| @@ -296,6 +299,7 @@ func TestTunnelRTTRate(t *testing.T) { | ||||
| 			t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate()) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestReconnectTunnel(t *testing.T) { | ||||
| 	// we manually override the tunnel.ReconnectTime value here | ||||
|   | ||||
| @@ -226,8 +226,8 @@ func (s *service) start() error { | ||||
| 		ch <- l.Close() | ||||
| 	}() | ||||
|  | ||||
| 	if logger.V(logger.InfoLevel, log) { | ||||
| 		log.Infof("Listening on %v", l.Addr().String()) | ||||
| 	if logger.V(logger.DebugLevel, log) { | ||||
| 		log.Debugf("Listening on %v", l.Addr().String()) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
| @@ -110,8 +110,10 @@ func TestService(t *testing.T) { | ||||
| 			t.Fatalf("service.Run():%v", err) | ||||
| 		} | ||||
| 	case <-time.After(time.Duration(time.Second)): | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("service.Run() survived a client request without an error") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	ch := make(chan os.Signal, 1) | ||||
| 	signal.Notify(ch, syscall.SIGTERM) | ||||
| @@ -125,11 +127,15 @@ func TestService(t *testing.T) { | ||||
| 		if err != nil { | ||||
| 			t.Fatalf("service.Run():%v", err) | ||||
| 		} else { | ||||
| 			if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 				t.Log("service.Run() nil return on syscall.SIGTERM") | ||||
| 			} | ||||
| 		} | ||||
| 	case <-time.After(time.Duration(time.Second)): | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("service.Run() survived a client request without an error") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	eventually(func() bool { | ||||
| 		_, err := reg.GetService("go.micro.web.test") | ||||
| @@ -286,7 +292,9 @@ func TestTLS(t *testing.T) { | ||||
| 			t.Fatalf("service.Run():%v", err) | ||||
| 		} | ||||
| 	case <-time.After(time.Duration(time.Second)): | ||||
| 		if len(os.Getenv("IN_TRAVIS_CI")) == 0 { | ||||
| 			t.Logf("service.Run() survived a client request without an error") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user