X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/afb710394b65fc82da8e4edd024a3a5fc1a18d54..8e75f57bd693d0ceb1aab86ba0e84cb19b4d155a:/services/arv-git-httpd/integration_test.go diff --git a/services/arv-git-httpd/integration_test.go b/services/arv-git-httpd/integration_test.go index 10c69eedd3..93a46e2248 100644 --- a/services/arv-git-httpd/integration_test.go +++ b/services/arv-git-httpd/integration_test.go @@ -12,8 +12,10 @@ import ( "strings" "testing" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/lib/config" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/ctxlog" check "gopkg.in/check.v1" ) @@ -28,20 +30,12 @@ type IntegrationSuite struct { tmpRepoRoot string tmpWorkdir string testServer *server - Config *Config -} - -func (s *IntegrationSuite) SetUpSuite(c *check.C) { - arvadostest.StartAPI() -} - -func (s *IntegrationSuite) TearDownSuite(c *check.C) { - arvadostest.StopAPI() + cluster *arvados.Cluster } func (s *IntegrationSuite) SetUpTest(c *check.C) { arvadostest.ResetEnv() - s.testServer = &server{} + var err error if s.tmpRepoRoot == "" { s.tmpRepoRoot, err = ioutil.TempDir("", "arv-git-httpd") @@ -51,15 +45,35 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) { c.Assert(err, check.Equals, nil) _, err = exec.Command("git", "init", "--bare", s.tmpRepoRoot+"/zzzzz-s0uqq-382brsig8rp3666.git").Output() c.Assert(err, check.Equals, nil) + // we need git 2.28 to specify the initial branch with -b; Buster only has 2.20; so we do it in 2 steps _, err = exec.Command("git", "init", s.tmpWorkdir).Output() c.Assert(err, check.Equals, nil) + _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && git checkout -b main").Output() + c.Assert(err, check.Equals, nil) _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo initial >initial && git add initial && git -c user.name=Initial -c user.email=Initial commit -am 'foo: initial commit'").CombinedOutput() c.Assert(err, check.Equals, nil) - _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && git push "+s.tmpRepoRoot+"/zzzzz-s0uqq-382brsig8rp3666.git master:master").CombinedOutput() + _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && git push "+s.tmpRepoRoot+"/zzzzz-s0uqq-382brsig8rp3666.git main:main").CombinedOutput() c.Assert(err, check.Equals, nil) _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo work >work && git add work && git -c user.name=Foo -c user.email=Foo commit -am 'workdir: test'").CombinedOutput() c.Assert(err, check.Equals, nil) + if s.cluster == nil { + cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load() + c.Assert(err, check.Equals, nil) + s.cluster, err = cfg.GetCluster("") + c.Assert(err, check.Equals, nil) + + s.cluster.Services.GitHTTP.InternalURLs = map[arvados.URL]arvados.ServiceInstance{{Host: "localhost:0"}: {}} + s.cluster.TLS.Insecure = true + s.cluster.Git.GitCommand = "/usr/bin/git" + s.cluster.Git.Repositories = s.tmpRepoRoot + s.cluster.ManagementToken = arvadostest.ManagementToken + } + + s.testServer = &server{cluster: s.cluster} + err = s.testServer.Start() + c.Assert(err, check.Equals, nil) + _, err = exec.Command("git", "config", "--file", s.tmpWorkdir+"/.git/config", "credential.http://"+s.testServer.Addr+"/.helper", @@ -71,29 +85,12 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) { "none").Output() c.Assert(err, check.Equals, nil) - if s.Config == nil { - s.Config = &Config{ - Client: arvados.Client{ - APIHost: arvadostest.APIHost(), - Insecure: true, - }, - Listen: ":0", - GitCommand: "/usr/bin/git", - RepoRoot: s.tmpRepoRoot, - ManagementToken: arvadostest.ManagementToken, - } - } - // Clear ARVADOS_API_* env vars before starting up the server, // to make sure arv-git-httpd doesn't use them or complain // about them being missing. os.Unsetenv("ARVADOS_API_HOST") os.Unsetenv("ARVADOS_API_HOST_INSECURE") os.Unsetenv("ARVADOS_API_TOKEN") - - theConfig = s.Config - err = s.testServer.Start() - c.Assert(err, check.Equals, nil) } func (s *IntegrationSuite) TearDownTest(c *check.C) { @@ -116,9 +113,7 @@ func (s *IntegrationSuite) TearDownTest(c *check.C) { } s.tmpWorkdir = "" - s.Config = nil - - theConfig = defaultConfig() + s.cluster = nil } func (s *IntegrationSuite) RunGit(c *check.C, token, gitCmd, repo string, args ...string) error {