Merge branch 'ce-backport-of-ml-web-terminal-spec-qa' into 'master'

Backport changes from EE MR 8186

See merge request gitlab-org/gitlab-ce!31707
This commit is contained in:
Dan Davison 2019-08-29 23:46:47 +00:00
commit 739ecdb664
11 changed files with 153 additions and 23 deletions

View file

@ -44,7 +44,7 @@ export default {
<template> <template>
<div class="flash-container flash-container-page" @click="clickFlash"> <div class="flash-container flash-container-page" @click="clickFlash">
<div class="flash-alert"> <div class="flash-alert" data-qa-selector="flash_alert">
<span v-html="message.text"> </span> <span v-html="message.text"> </span>
<button <button
v-if="message.action" v-if="message.action"

View file

@ -89,7 +89,7 @@ export default {
</script> </script>
<template> <template>
<div class="multi-file-commit-panel ide-right-sidebar"> <div class="multi-file-commit-panel ide-right-sidebar" data-qa-selector="ide_right_sidebar">
<resizable-panel <resizable-panel
v-show="isOpen" v-show="isOpen"
:collapsible="false" :collapsible="false"
@ -120,6 +120,7 @@ export default {
}" }"
data-container="body" data-container="body"
data-placement="left" data-placement="left"
:data-qa-selector="`${tab.title.toLowerCase()}_tab_button`"
class="ide-sidebar-link is-right" class="ide-sidebar-link is-right"
type="button" type="button"
@click="clickTab($event, tab)" @click="clickTab($event, tab)"

View file

@ -73,6 +73,7 @@ module QA
end end
module Repository module Repository
autoload :Commit, 'qa/resource/repository/commit'
autoload :Push, 'qa/resource/repository/push' autoload :Push, 'qa/resource/repository/push'
autoload :ProjectPush, 'qa/resource/repository/project_push' autoload :ProjectPush, 'qa/resource/repository/project_push'
autoload :WikiPush, 'qa/resource/repository/wiki_push' autoload :WikiPush, 'qa/resource/repository/wiki_push'
@ -346,6 +347,10 @@ module QA
module Issuable module Issuable
autoload :Common, 'qa/page/component/issuable/common' autoload :Common, 'qa/page/component/issuable/common'
end end
module WebIDE
autoload :Alert, 'qa/page/component/web_ide/alert'
end
end end
end end

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
module QA
module Page
module Component
module WebIDE
module Alert
def self.prepended(page)
page.module_eval do
view 'app/assets/javascripts/ide/components/error_message.vue' do
element :flash_alert
end
end
end
def has_no_alert?(message = nil)
return has_no_element?(:flash_alert) if message.nil?
within_element(:flash_alert) do
has_no_text?(message)
end
end
end
end
end
end
end

View file

@ -5,6 +5,7 @@ module QA
module Project module Project
module WebIDE module WebIDE
class Edit < Page::Base class Edit < Page::Base
prepend Page::Component::WebIDE::Alert
include Page::Component::DropdownFilter include Page::Component::DropdownFilter
view 'app/assets/javascripts/ide/components/activity_bar.vue' do view 'app/assets/javascripts/ide/components/activity_bar.vue' do
@ -123,3 +124,5 @@ module QA
end end
end end
end end
QA::Page::Project::WebIDE::Edit.prepend_if_ee('QA::EE::Page::Component::WebIDE::WebTerminalPanel')

View file

@ -15,6 +15,7 @@ module QA
attribute :add_name_uuid attribute :add_name_uuid
attribute :description attribute :description
attribute :standalone attribute :standalone
attribute :runners_token
attribute :group do attribute :group do
Group.fabricate! Group.fabricate!

View file

@ -0,0 +1,66 @@
# frozen_string_literal: true
module QA
module Resource
module Repository
class Commit < Base
attr_accessor :author_email,
:author_name,
:branch,
:commit_message,
:file_path,
:sha
attribute :project do
Project.fabricate! do |resource|
resource.name = 'project-with-commit'
end
end
def initialize
@commit_message = 'QA Test - Commit message'
end
def files=(files)
if !files.is_a?(Array) ||
files.empty? ||
files.any? { |file| !file.has_key?(:file_path) || !file.has_key?(:content) }
raise ArgumentError, "Please provide an array of hashes e.g.: [{file_path: 'file1', content: 'foo'}]"
end
@files = files
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"#{api_post_path}/#{@sha}"
end
def api_post_path
"/projects/#{CGI.escape(project.path_with_namespace)}/repository/commits"
end
def api_post_body
{
branch: @branch || "master",
author_email: @author_email || Runtime::User.default_email,
author_name: @author_name || Runtime::User.username,
commit_message: commit_message,
actions: actions
}
end
def actions
@files.map do |file|
file.merge({ action: "create" })
end
end
end
end
end
end

View file

@ -6,9 +6,10 @@ module QA
module Resource module Resource
class Runner < Base class Runner < Base
attr_writer :name, :tags, :image attr_writer :name, :tags, :image
attr_accessor :config
attribute :project do attribute :project do
Project.fabricate! do |resource| Project.fabricate_via_api! do |resource|
resource.name = 'project-with-ci-cd' resource.name = 'project-with-ci-cd'
resource.description = 'Project with CI/CD Pipelines' resource.description = 'Project with CI/CD Pipelines'
end end
@ -26,24 +27,27 @@ module QA
@image || 'gitlab/gitlab-runner:alpine' @image || 'gitlab/gitlab-runner:alpine'
end end
def fabricate! def fabricate_via_api!
project.visit!
Page::Project::Menu.perform(&:go_to_ci_cd_settings)
Service::Runner.new(name).tap do |runner| Service::Runner.new(name).tap do |runner|
Page::Project::Settings::CICD.perform do |settings| runner.pull
settings.expand_runners_settings do |runners| runner.token = project.runners_token
runner.pull runner.address = Runtime::Scenario.gitlab_address
runner.token = runners.registration_token runner.tags = tags
runner.address = runners.coordinator_address runner.image = image
runner.tags = tags runner.config = config if config
runner.image = image runner.run_untagged = true
runner.register! runner.register!
end
end
end end
end end
def api_get_path
end
def api_post_path
end
def api_post_body
end
end end
end end
end end

View file

@ -7,13 +7,25 @@ module QA
class Runner class Runner
include Service::Shellout include Service::Shellout
attr_accessor :token, :address, :tags, :image attr_accessor :token, :address, :tags, :image, :run_untagged
attr_writer :config
def initialize(name) def initialize(name)
@image = 'gitlab/gitlab-runner:alpine' @image = 'gitlab/gitlab-runner:alpine'
@name = name || "qa-runner-#{SecureRandom.hex(4)}" @name = name || "qa-runner-#{SecureRandom.hex(4)}"
@network = Runtime::Scenario.attributes[:network] || 'test' @network = Runtime::Scenario.attributes[:network] || 'test'
@tags = %w[qa test] @tags = %w[qa test]
@run_untagged = false
end
def config
@config ||= <<~END
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
END
end end
def network def network
@ -32,19 +44,30 @@ module QA
shell <<~CMD.tr("\n", ' ') shell <<~CMD.tr("\n", ' ')
docker run -d --rm --entrypoint=/bin/sh docker run -d --rm --entrypoint=/bin/sh
--network #{network} --name #{@name} --network #{network} --name #{@name}
-p 8093:8093
-e CI_SERVER_URL=#{@address} -e CI_SERVER_URL=#{@address}
-e REGISTER_NON_INTERACTIVE=true -e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=#{@token} -e REGISTRATION_TOKEN=#{@token}
-e RUNNER_EXECUTOR=shell -e RUNNER_EXECUTOR=shell
-e RUNNER_TAG_LIST=#{@tags.join(',')} -e RUNNER_TAG_LIST=#{@tags.join(',')}
-e RUNNER_NAME=#{@name} -e RUNNER_NAME=#{@name}
#{@image} -c 'gitlab-runner register && gitlab-runner run' #{@image} -c "#{register_command}"
CMD CMD
end end
def remove! def remove!
shell "docker rm -f #{@name}" shell "docker rm -f #{@name}"
end end
private
def register_command
<<~CMD
printf '#{config.chomp.gsub(/\n/, "\\n").gsub('"', '\"')}' > /etc/gitlab-runner/config.toml &&
gitlab-runner register --run-untagged=#{@run_untagged} &&
gitlab-runner run
CMD
end
end end
end end
end end

View file

@ -15,11 +15,11 @@ module QA
Resource::Runner.fabricate! do |runner| Resource::Runner.fabricate! do |runner|
runner.name = executor runner.name = executor
end end.project.visit!
Page::Project::Menu.perform(&:go_to_ci_cd_settings)
Page::Project::Settings::CICD.perform do |settings| Page::Project::Settings::CICD.perform do |settings|
sleep 5 # Runner should register within 5 seconds sleep 5 # Runner should register within 5 seconds
settings.refresh
settings.expand_runners_settings do |page| settings.expand_runners_settings do |page|
expect(page).to have_content(executor) expect(page).to have_content(executor)

View file

@ -17,7 +17,7 @@ module QA
@repository_location = @project.repository_ssh_location @repository_location = @project.repository_ssh_location
Resource::Runner.fabricate_via_browser_ui! do |resource| Resource::Runner.fabricate_via_api! do |resource|
resource.project = @project resource.project = @project
resource.name = @runner_name resource.name = @runner_name
resource.tags = %w[qa docker] resource.tags = %w[qa docker]