Skip to content
代码片段 群组 项目
未验证 提交 c8dd1f09 编辑于 作者: Sanad Liaquat's avatar Sanad Liaquat 提交者: GitLab
浏览文件

Merge branch 'andrey-remove-sandbox-name-caching' into 'master'

Remove sandbox name caching

Closes gitlab-org/quality/quality-engineering/team-tasks#3092

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/169390



Merged-by: default avatarSanad Liaquat <sliaquat@gitlab.com>
Approved-by: default avatarSanad Liaquat <sliaquat@gitlab.com>
Reviewed-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
Co-authored-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -18,16 +18,26 @@ def group_name
Env.namespace_name || "qa-test-#{time.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(8)}"
end
# Predefined top level group name
# Top level group name
#
# @return [String]
def sandbox_name
@sandbox_name ||= Runtime::Env.sandbox_name ||
if !QA::Runtime::Env.running_on_dot_com? && QA::Runtime::Env.run_in_parallel?
"gitlab-qa-sandbox-group-#{SecureRandom.hex(4)}-#{Time.now.wday + 1}"
else
"gitlab-qa-sandbox-group-#{Time.now.wday + 1}"
end
return "gitlab-qa-sandbox-group-#{Time.now.wday + 1}" if live_env?
"qa-sandbox-#{SecureRandom.hex(6)}"
end
private
# Test is running on live environment with limitations for top level group creation
#
# @return [Boolean]
def live_env?
return @live_env unless @live_env.nil?
# Memoize the result of this check so every call doesn't parse gitlab address and check hostname
# There is no case to change gitlab address in the middle of test process so it should be safe to do
@live_env = Runtime::Env.running_on_dot_com? || Runtime::Env.running_on_release?
end
end
end
......
......@@ -7,7 +7,6 @@
before(:context) do
described_class.instance_variable_set(:@time, nil)
described_class.instance_variable_set(:@sandbox_name, nil)
end
describe '.group_name' do
......@@ -17,12 +16,37 @@
end
describe '.sandbox_name' do
let(:dot_com) { false }
let(:release) { false }
before do
allow(QA::Runtime::Scenario).to receive(:gitlab_address).and_return("http://gitlab.test")
described_class.instance_variable_set(:@live_env, nil)
allow(QA::Runtime::Env).to receive_messages(
running_on_dot_com?: dot_com,
running_on_release?: release
)
end
context "when running on .com environment" do
let(:dot_com) { true }
it "returns day specific sandbox name" do
expect(described_class.sandbox_name).to match(%r{gitlab-qa-sandbox-group-#{time.wday + 1}})
end
end
context "when running on release environment" do
let(:release) { true }
it "returns day specific sandbox name" do
expect(described_class.sandbox_name).to match(%r{gitlab-qa-sandbox-group-#{time.wday + 1}})
end
end
it "returns day specific sandbox name" do
expect(described_class.sandbox_name).to match(%r{gitlab-qa-sandbox-group-#{time.wday + 1}})
context "when running on ephemeral environment" do
it "returns random sandbox name" do
expect(described_class.sandbox_name).to match(/qa-sandbox-[a-f0-9]{12}/)
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册