mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Improved logs in integration tests
This commit is contained in:
		
							parent
							
								
									0eb3b23f16
								
							
						
					
					
						commit
						a6113066ff
					
				@ -73,21 +73,22 @@ func (s *IntegrationCLITestSuite) SetupTest() {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Println("Creating headscale container")
 | 
			
		||||
	fmt.Println("Creating headscale container for CLI tests")
 | 
			
		||||
	if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
 | 
			
		||||
		s.headscale = *pheadscale
 | 
			
		||||
	} else {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Println("Created headscale container")
 | 
			
		||||
	fmt.Println("Created headscale container for CLI tests")
 | 
			
		||||
 | 
			
		||||
	fmt.Println("Waiting for headscale to be ready")
 | 
			
		||||
	fmt.Println("Waiting for headscale to be ready for CLI tests")
 | 
			
		||||
	hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
 | 
			
		||||
 | 
			
		||||
	if err := s.pool.Retry(func() error {
 | 
			
		||||
		url := fmt.Sprintf("http://%s/health", hostEndpoint)
 | 
			
		||||
		resp, err := http.Get(url)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Printf("headscale for CLI test is not ready: %s\n", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		if resp.StatusCode != http.StatusOK {
 | 
			
		||||
@ -102,7 +103,7 @@ func (s *IntegrationCLITestSuite) SetupTest() {
 | 
			
		||||
		// https://github.com/stretchr/testify/issues/849
 | 
			
		||||
		return // fmt.Errorf("Could not connect to headscale: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Println("headscale container is ready")
 | 
			
		||||
	fmt.Println("headscale container is ready for CLI tests")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *IntegrationCLITestSuite) TearDownTest() {
 | 
			
		||||
 | 
			
		||||
@ -134,15 +134,15 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Println("Creating headscale container")
 | 
			
		||||
	log.Println("Creating headscale container for DERP integration tests")
 | 
			
		||||
	if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
 | 
			
		||||
		s.headscale = *pheadscale
 | 
			
		||||
	} else {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
	log.Println("Created headscale container to test DERP")
 | 
			
		||||
	log.Println("Created headscale container for embedded DERP tests")
 | 
			
		||||
 | 
			
		||||
	log.Println("Creating tailscale containers")
 | 
			
		||||
	log.Println("Creating tailscale containers for embedded DERP tests")
 | 
			
		||||
 | 
			
		||||
	for i := 0; i < totalContainers; i++ {
 | 
			
		||||
		version := tailscaleVersions[i%len(tailscaleVersions)]
 | 
			
		||||
@ -154,7 +154,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
 | 
			
		||||
		s.tailscales[hostname] = *container
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Println("Waiting for headscale to be ready")
 | 
			
		||||
	log.Println("Waiting for headscale to be ready for embedded DERP tests")
 | 
			
		||||
	hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8443/tcp"))
 | 
			
		||||
 | 
			
		||||
	if err := s.pool.Retry(func() error {
 | 
			
		||||
@ -164,6 +164,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
 | 
			
		||||
		client := &http.Client{Transport: insecureTransport}
 | 
			
		||||
		resp, err := client.Get(url)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Printf("headscale for embedded DERP tests is not ready: %s\n", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -179,7 +180,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
 | 
			
		||||
		// https://github.com/stretchr/testify/issues/849
 | 
			
		||||
		return // fmt.Errorf("Could not connect to headscale: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	log.Println("headscale container is ready")
 | 
			
		||||
	log.Println("headscale container is ready for embedded DERP tests")
 | 
			
		||||
 | 
			
		||||
	log.Printf("Creating headscale namespace: %s\n", namespaceName)
 | 
			
		||||
	result, err := ExecuteCommand(
 | 
			
		||||
 | 
			
		||||
@ -251,15 +251,15 @@ func (s *IntegrationTestSuite) SetupSuite() {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Println("Creating headscale container")
 | 
			
		||||
	log.Println("Creating headscale container for core integration tests")
 | 
			
		||||
	if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
 | 
			
		||||
		s.headscale = *pheadscale
 | 
			
		||||
	} else {
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
 | 
			
		||||
		s.FailNow(fmt.Sprintf("Could not start headscale container for core integration tests: %s", err), "")
 | 
			
		||||
	}
 | 
			
		||||
	log.Println("Created headscale container")
 | 
			
		||||
	log.Println("Created headscale container for core integration tests")
 | 
			
		||||
 | 
			
		||||
	log.Println("Creating tailscale containers")
 | 
			
		||||
	log.Println("Creating tailscale containers for core integration tests")
 | 
			
		||||
	for namespace, scales := range s.namespaces {
 | 
			
		||||
		for i := 0; i < scales.count; i++ {
 | 
			
		||||
			version := tailscaleVersions[i%len(tailscaleVersions)]
 | 
			
		||||
@ -273,7 +273,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Println("Waiting for headscale to be ready")
 | 
			
		||||
	log.Println("Waiting for headscale to be ready for core integration tests")
 | 
			
		||||
	hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
 | 
			
		||||
 | 
			
		||||
	if err := s.pool.Retry(func() error {
 | 
			
		||||
@ -281,6 +281,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
 | 
			
		||||
 | 
			
		||||
		resp, err := http.Get(url)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Printf("headscale for core integration test is not ready: %s\n", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -296,7 +297,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
 | 
			
		||||
		// https://github.com/stretchr/testify/issues/849
 | 
			
		||||
		return // fmt.Errorf("Could not connect to headscale: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	log.Println("headscale container is ready")
 | 
			
		||||
	log.Println("headscale container is ready for core integration tests")
 | 
			
		||||
 | 
			
		||||
	for namespace, scales := range s.namespaces {
 | 
			
		||||
		log.Printf("Creating headscale namespace: %s\n", namespace)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user