github.com/argoproj/argo-cd@v1.8.7/reposerver/repository/repository_norace_test.go (about)

     1  // +build !race
     2  
     3  package repository
     4  
     5  import (
     6  	"os"
     7  	"path/filepath"
     8  	"sync"
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  
    13  	argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
    14  	"github.com/argoproj/argo-cd/reposerver/apiclient"
    15  )
    16  
    17  func TestHelmDependencyWithConcurrency(t *testing.T) {
    18  
    19  	// !race:
    20  	// Un-synchronized use of a random source, will be fixed when this is merged:
    21  	// https://github.com/argoproj/argo-cd/issues/4728
    22  
    23  	cleanup := func() {
    24  		_ = os.Remove(filepath.Join("../../util/helm/testdata/helm2-dependency", helmDepUpMarkerFile))
    25  		_ = os.RemoveAll(filepath.Join("../../util/helm/testdata/helm2-dependency", "charts"))
    26  	}
    27  	cleanup()
    28  	defer cleanup()
    29  
    30  	helmRepo := argoappv1.Repository{Name: "bitnami", Type: "helm", Repo: "https://charts.bitnami.com/bitnami"}
    31  	var wg sync.WaitGroup
    32  	wg.Add(3)
    33  	for i := 0; i < 3; i++ {
    34  		go func() {
    35  			res, err := helmTemplate("../../util/helm/testdata/helm2-dependency", "../..", nil, &apiclient.ManifestRequest{
    36  				ApplicationSource: &argoappv1.ApplicationSource{},
    37  				Repos:             []*argoappv1.Repository{&helmRepo},
    38  			}, false)
    39  
    40  			assert.NoError(t, err)
    41  			assert.NotNil(t, res)
    42  			wg.Done()
    43  		}()
    44  	}
    45  	wg.Wait()
    46  }