Merge pull request #82 from sgotti/tests_test_also_clone_step
tests: test also clone step
This commit is contained in:
commit
0da52e2d8a
|
@ -15,7 +15,7 @@ local dind_runtime(arch) = {
|
|||
{
|
||||
image: 'docker:stable-dind',
|
||||
privileged: true,
|
||||
entrypoint: 'dockerd',
|
||||
entrypoint: 'dockerd --bip 172.18.0.1/16',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ local task_build_docker_tests(version, arch) = {
|
|||
|||,
|
||||
},
|
||||
{ type: 'restore_workspace', dest_dir: '.' },
|
||||
{ type: 'run', name: 'integration tests', command: 'AGOLA_TOOLBOX_PATH="./bin" GITEA_PATH=${PWD}/bin/gitea ./bin/integration-tests -test.parallel 1 -test.v' },
|
||||
{ type: 'run', name: 'integration tests', command: 'AGOLA_TOOLBOX_PATH="./bin" GITEA_PATH=${PWD}/bin/gitea DOCKER_BRIDGE_ADDRESS="172.18.0.1" ./bin/integration-tests -test.parallel 1 -test.v' },
|
||||
],
|
||||
depends: [
|
||||
'build go 1.12 amd64',
|
||||
|
|
|
@ -360,9 +360,9 @@ TEMP_PATH = {{ .Data }}/gitea/uploads
|
|||
|
||||
[server]
|
||||
APP_DATA_PATH = {{ .Data }}/gitea
|
||||
SSH_DOMAIN = {{ .ListenAddress }}
|
||||
SSH_DOMAIN = {{ .SSHListenAddress }}
|
||||
HTTP_PORT = {{ .HTTPPort }}
|
||||
ROOT_URL = http://{{ .ListenAddress }}:{{ .HTTPPort }}/
|
||||
ROOT_URL = http://{{ .HTTPListenAddress }}:{{ .HTTPPort }}/
|
||||
DISABLE_SSH = false
|
||||
# Use built-in ssh server
|
||||
START_SSH_SERVER = true
|
||||
|
@ -432,24 +432,26 @@ ENABLE_OPENID_SIGNUP = true
|
|||
)
|
||||
|
||||
type GiteaConfig struct {
|
||||
Data string
|
||||
User string
|
||||
ListenAddress string
|
||||
HTTPPort string
|
||||
SSHPort string
|
||||
Data string
|
||||
User string
|
||||
HTTPListenAddress string
|
||||
HTTPPort string
|
||||
SSHListenAddress string
|
||||
SSHPort string
|
||||
}
|
||||
|
||||
type TestGitea struct {
|
||||
Process
|
||||
|
||||
GiteaPath string
|
||||
ConfigPath string
|
||||
ListenAddress string
|
||||
HTTPPort string
|
||||
SSHPort string
|
||||
GiteaPath string
|
||||
ConfigPath string
|
||||
HTTPListenAddress string
|
||||
HTTPPort string
|
||||
SSHListenAddress string
|
||||
SSHPort string
|
||||
}
|
||||
|
||||
func NewTestGitea(t *testing.T, logger *zap.Logger, dir string, a ...string) (*TestGitea, error) {
|
||||
func NewTestGitea(t *testing.T, logger *zap.Logger, dir, dockerBridgeAddress string, a ...string) (*TestGitea, error) {
|
||||
u := uuid.NewV4()
|
||||
uid := fmt.Sprintf("%x", u[:4])
|
||||
|
||||
|
@ -475,11 +477,12 @@ func NewTestGitea(t *testing.T, logger *zap.Logger, dir string, a ...string) (*T
|
|||
}
|
||||
|
||||
giteaConfig := &GiteaConfig{
|
||||
Data: giteaDir,
|
||||
User: curUser.Username,
|
||||
ListenAddress: listenAddress,
|
||||
HTTPPort: httpPort,
|
||||
SSHPort: sshPort,
|
||||
Data: giteaDir,
|
||||
User: curUser.Username,
|
||||
HTTPListenAddress: listenAddress,
|
||||
SSHListenAddress: dockerBridgeAddress,
|
||||
HTTPPort: httpPort,
|
||||
SSHPort: sshPort,
|
||||
}
|
||||
tmpl, err := template.New("gitea").Parse(giteaAppIniTmpl)
|
||||
if err != nil {
|
||||
|
@ -512,11 +515,12 @@ func NewTestGitea(t *testing.T, logger *zap.Logger, dir string, a ...string) (*T
|
|||
bin: giteaPath,
|
||||
args: args,
|
||||
},
|
||||
GiteaPath: giteaPath,
|
||||
ConfigPath: configPath,
|
||||
ListenAddress: listenAddress,
|
||||
HTTPPort: httpPort,
|
||||
SSHPort: sshPort,
|
||||
GiteaPath: giteaPath,
|
||||
ConfigPath: configPath,
|
||||
HTTPListenAddress: listenAddress,
|
||||
HTTPPort: httpPort,
|
||||
SSHListenAddress: dockerBridgeAddress,
|
||||
SSHPort: sshPort,
|
||||
}
|
||||
|
||||
return tgitea, nil
|
||||
|
|
|
@ -81,8 +81,8 @@ func shutdownEtcd(tetcd *testutil.TestEmbeddedEtcd) {
|
|||
}
|
||||
}
|
||||
|
||||
func setupGitea(t *testing.T, dir string) *testutil.TestGitea {
|
||||
tgitea, err := testutil.NewTestGitea(t, logger, dir)
|
||||
func setupGitea(t *testing.T, dir, dockerBridgeAddress string) *testutil.TestGitea {
|
||||
tgitea, err := testutil.NewTestGitea(t, logger, dir, dockerBridgeAddress)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
|
@ -156,6 +156,10 @@ func startAgola(ctx context.Context, t *testing.T, dir string, c *config.Config)
|
|||
}
|
||||
|
||||
func setup(ctx context.Context, t *testing.T, dir string) (*testutil.TestEmbeddedEtcd, *testutil.TestGitea, *config.Config) {
|
||||
dockerBridgeAddress := os.Getenv("DOCKER_BRIDGE_ADDRESS")
|
||||
if dockerBridgeAddress == "" {
|
||||
dockerBridgeAddress = "172.17.0.1"
|
||||
}
|
||||
toolboxPath := os.Getenv("AGOLA_TOOLBOX_PATH")
|
||||
if toolboxPath == "" {
|
||||
t.Fatalf("env var AGOLA_TOOLBOX_PATH is undefined")
|
||||
|
@ -253,7 +257,7 @@ func setup(ctx context.Context, t *testing.T, dir string) (*testutil.TestEmbedde
|
|||
},
|
||||
}
|
||||
|
||||
tgitea := setupGitea(t, dir)
|
||||
tgitea := setupGitea(t, dir, dockerBridgeAddress)
|
||||
|
||||
etcdDir := filepath.Join(dir, "etcd")
|
||||
tetcd := setupEtcd(t, etcdDir)
|
||||
|
@ -282,16 +286,16 @@ func setup(ctx context.Context, t *testing.T, dir string) (*testutil.TestEmbedde
|
|||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
|
||||
gwURL := fmt.Sprintf("http://%s:%s", listenAddress, gwPort)
|
||||
gwURL := fmt.Sprintf("http://%s:%s", dockerBridgeAddress, gwPort)
|
||||
csURL := fmt.Sprintf("http://%s:%s", listenAddress, csPort)
|
||||
rsURL := fmt.Sprintf("http://%s:%s", listenAddress, rsPort)
|
||||
gitServerURL := fmt.Sprintf("http://%s:%s", listenAddress, gitServerPort)
|
||||
gitServerURL := fmt.Sprintf("http://%s:%s", dockerBridgeAddress, gitServerPort)
|
||||
|
||||
c.Gateway.Web.ListenAddress = fmt.Sprintf("%s:%s", listenAddress, gwPort)
|
||||
c.Gateway.Web.ListenAddress = fmt.Sprintf("%s:%s", dockerBridgeAddress, gwPort)
|
||||
c.Configstore.Web.ListenAddress = fmt.Sprintf("%s:%s", listenAddress, csPort)
|
||||
c.Runservice.Web.ListenAddress = fmt.Sprintf("%s:%s", listenAddress, rsPort)
|
||||
c.Executor.Web.ListenAddress = fmt.Sprintf("%s:%s", listenAddress, exPort)
|
||||
c.Gitserver.Web.ListenAddress = fmt.Sprintf("%s:%s", listenAddress, gitServerPort)
|
||||
c.Gitserver.Web.ListenAddress = fmt.Sprintf("%s:%s", dockerBridgeAddress, gitServerPort)
|
||||
|
||||
c.Gateway.APIExposedURL = gwURL
|
||||
c.Gateway.WebExposedURL = gwURL
|
||||
|
@ -339,7 +343,7 @@ func TestCreateLinkedAccount(t *testing.T) {
|
|||
}
|
||||
|
||||
func createLinkedAccount(ctx context.Context, t *testing.T, tgitea *testutil.TestGitea, c *config.Config) (string, string) {
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.ListenAddress, tgitea.HTTPPort)
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.HTTPListenAddress, tgitea.HTTPPort)
|
||||
giteaClient := gitea.NewClient(giteaAPIURL, "")
|
||||
|
||||
giteaToken, err := giteaClient.CreateAccessToken(giteaUser01, "password", gtypes.CreateAccessTokenOption{Name: "token01"})
|
||||
|
@ -403,7 +407,7 @@ func TestCreateProject(t *testing.T) {
|
|||
defer shutdownGitea(tgitea)
|
||||
defer shutdownEtcd(tetcd)
|
||||
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.ListenAddress, tgitea.HTTPPort)
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.HTTPListenAddress, tgitea.HTTPPort)
|
||||
|
||||
giteaToken, token := createLinkedAccount(ctx, t, tgitea, c)
|
||||
|
||||
|
@ -450,7 +454,7 @@ func TestRun(t *testing.T) {
|
|||
defer shutdownGitea(tgitea)
|
||||
defer shutdownEtcd(tetcd)
|
||||
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.ListenAddress, tgitea.HTTPPort)
|
||||
giteaAPIURL := fmt.Sprintf("http://%s:%s", tgitea.HTTPListenAddress, tgitea.HTTPPort)
|
||||
|
||||
giteaToken, token := createLinkedAccount(ctx, t, tgitea, c)
|
||||
|
||||
|
@ -475,11 +479,12 @@ func TestRun(t *testing.T) {
|
|||
runtime: {
|
||||
containers: [
|
||||
{
|
||||
image: 'busybox',
|
||||
image: 'alpine/git',
|
||||
},
|
||||
],
|
||||
},
|
||||
steps: [
|
||||
{ type: 'clone' },
|
||||
{ type: 'run', command: 'env' },
|
||||
],
|
||||
},
|
||||
|
@ -551,4 +556,7 @@ func TestRun(t *testing.T) {
|
|||
if run.Phase != rstypes.RunPhaseFinished {
|
||||
t.Fatalf("expected run phase %q, got %q", rstypes.RunPhaseFinished, run.Phase)
|
||||
}
|
||||
if run.Result != rstypes.RunResultSuccess {
|
||||
t.Fatalf("expected run result %q, got %q", rstypes.RunResultSuccess, run.Result)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue