summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/README.md24
-rw-r--r--qa/qa/page/main/login.rb10
-rw-r--r--qa/qa/runtime/env.rb22
-rw-r--r--qa/qa/runtime/namespace.rb2
-rw-r--r--qa/qa/runtime/user.rb8
-rw-r--r--qa/qa/service/runner.rb10
-rw-r--r--qa/qa/service/shellout.rb4
-rw-r--r--qa/qa/specs/features/project/pipelines_spec.rb4
-rw-r--r--qa/spec/runtime/env_spec.rb21
9 files changed, 97 insertions, 8 deletions
diff --git a/qa/README.md b/qa/README.md
index 3c1b61900d9..3a99a30d379 100644
--- a/qa/README.md
+++ b/qa/README.md
@@ -70,6 +70,30 @@ If you need to authenticate as a different user, you can provide the
GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password bin/qa Test::Instance https://gitlab.example.com
```
+If your user doesn't have permission to default sandbox group
+`gitlab-qa-sandbox`, you could also use another sandbox group by giving
+`GITLAB_SANDBOX_NAME`:
+
+```
+GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance https://gitlab.example.com
+```
+
+In addition, the `GITLAB_USER_TYPE` can be set to "ldap" to sign in as an LDAP user:
+
+```
+GITLAB_USER_TYPE=ldap GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance https://gitlab.example.com
+```
+
All [supported environment variables are here](https://gitlab.com/gitlab-org/gitlab-qa#supported-environment-variables).
+### Building a Docker image to test
+
+Once you have made changes to the CE/EE repositories, you may want to build a
+Docker image to test locally instead of waiting for the `gitlab-ce-qa` or
+`gitlab-ee-qa` nightly builds. To do that, you can run from this directory:
+
+```sh
+docker build -t gitlab/gitlab-ce-qa:nightly .
+```
+
[GDK]: https://gitlab.com/gitlab-org/gitlab-development-kit/
diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb
index fd49b27cb1a..a8a5601dbe6 100644
--- a/qa/qa/page/main/login.rb
+++ b/qa/qa/page/main/login.rb
@@ -39,6 +39,14 @@ module QA
end
end
+ def sign_in_using_credentials
+ if Runtime::User.ldap_user?
+ sign_in_using_ldap_credentials
+ else
+ sign_in_using_gitlab_credentials
+ end
+ end
+
def sign_in_using_ldap_credentials
using_wait_time 0 do
set_initial_password_if_present
@@ -51,7 +59,7 @@ module QA
end
end
- def sign_in_using_credentials
+ def sign_in_using_gitlab_credentials
using_wait_time 0 do
set_initial_password_if_present
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 56944e8b641..5401372e225 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -16,6 +16,28 @@ module QA
def personal_access_token
ENV['PERSONAL_ACCESS_TOKEN']
end
+
+ # By default, "standard" denotes a standard GitLab user login.
+ # Set this to "ldap" if the user should be logged in via LDAP.
+ def user_type
+ (ENV['GITLAB_USER_TYPE'] || 'standard').tap do |type|
+ unless %w(ldap standard).include?(type)
+ raise ArgumentError.new("Invalid user type '#{type}': must be 'ldap' or 'standard'")
+ end
+ end
+ end
+
+ def user_username
+ ENV['GITLAB_USERNAME']
+ end
+
+ def user_password
+ ENV['GITLAB_PASSWORD']
+ end
+
+ def sandbox_name
+ ENV['GITLAB_SANDBOX_NAME']
+ end
end
end
end
diff --git a/qa/qa/runtime/namespace.rb b/qa/qa/runtime/namespace.rb
index a72c2d21898..8d05b387416 100644
--- a/qa/qa/runtime/namespace.rb
+++ b/qa/qa/runtime/namespace.rb
@@ -16,7 +16,7 @@ module QA
end
def sandbox_name
- 'gitlab-qa-sandbox'
+ Runtime::Env.sandbox_name || 'gitlab-qa-sandbox'
end
end
end
diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb
index 60027c89ab1..39e6adf9522 100644
--- a/qa/qa/runtime/user.rb
+++ b/qa/qa/runtime/user.rb
@@ -4,11 +4,15 @@ module QA
extend self
def name
- ENV['GITLAB_USERNAME'] || 'root'
+ Runtime::Env.user_username || 'root'
end
def password
- ENV['GITLAB_PASSWORD'] || '5iveL!fe'
+ Runtime::Env.user_password || '5iveL!fe'
+ end
+
+ def ldap_user?
+ Runtime::Env.user_type == 'ldap'
end
end
end
diff --git a/qa/qa/service/runner.rb b/qa/qa/service/runner.rb
index d0ee33c69f2..c0352e0467a 100644
--- a/qa/qa/service/runner.rb
+++ b/qa/qa/service/runner.rb
@@ -15,6 +15,14 @@ module QA
@tags = %w[qa test]
end
+ def network
+ shell "docker network inspect #{@network}"
+ rescue CommandError
+ 'bridge'
+ else
+ @network
+ end
+
def pull
shell "docker pull #{@image}"
end
@@ -22,7 +30,7 @@ module QA
def register!
shell <<~CMD.tr("\n", ' ')
docker run -d --rm --entrypoint=/bin/sh
- --network #{@network} --name #{@name}
+ --network #{network} --name #{@name}
-e CI_SERVER_URL=#{@address}
-e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=#{@token}
diff --git a/qa/qa/service/shellout.rb b/qa/qa/service/shellout.rb
index 898febde63c..76fb2af6319 100644
--- a/qa/qa/service/shellout.rb
+++ b/qa/qa/service/shellout.rb
@@ -3,6 +3,8 @@ require 'open3'
module QA
module Service
module Shellout
+ CommandError = Class.new(StandardError)
+
##
# TODO, make it possible to use generic QA framework classes
# as a library - gitlab-org/gitlab-qa#94
@@ -14,7 +16,7 @@ module QA
out.each { |line| puts line }
if wait.value.exited? && wait.value.exitstatus.nonzero?
- raise "Command `#{command}` failed!"
+ raise CommandError, "Command `#{command}` failed!"
end
end
end
diff --git a/qa/qa/specs/features/project/pipelines_spec.rb b/qa/qa/specs/features/project/pipelines_spec.rb
index 1bb7730e06c..74f6474443d 100644
--- a/qa/qa/specs/features/project/pipelines_spec.rb
+++ b/qa/qa/specs/features/project/pipelines_spec.rb
@@ -69,7 +69,7 @@ module QA
tags:
- qa
- test
- script: echo "CONTENTS" > my-artifacts/artifact.txt
+ script: mkdir my-artifacts; echo "CONTENTS" > my-artifacts/artifact.txt
artifacts:
paths:
- my-artifacts/
@@ -95,7 +95,7 @@ module QA
expect(pipeline).to have_build('test-success', status: :success)
expect(pipeline).to have_build('test-failure', status: :failed)
expect(pipeline).to have_build('test-tags', status: :pending)
- expect(pipeline).to have_build('test-artifacts', status: :failed)
+ expect(pipeline).to have_build('test-artifacts', status: :success)
end
end
end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 103573db6be..2b6365dbc41 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -55,4 +55,25 @@ describe QA::Runtime::Env do
end
end
end
+
+ describe '.user_type' do
+ it 'returns standard if not defined' do
+ expect(described_class.user_type).to eq('standard')
+ end
+
+ it 'returns standard as defined' do
+ stub_env('GITLAB_USER_TYPE', 'standard')
+ expect(described_class.user_type).to eq('standard')
+ end
+
+ it 'returns ldap as defined' do
+ stub_env('GITLAB_USER_TYPE', 'ldap')
+ expect(described_class.user_type).to eq('ldap')
+ end
+
+ it 'returns an error if invalid user type' do
+ stub_env('GITLAB_USER_TYPE', 'foobar')
+ expect { described_class.user_type }.to raise_error(ArgumentError)
+ end
+ end
end