Maintenance: switch to Docker based OTRS import testing rather than using external services.

This commit is contained in:
Martin Gruner 2021-06-16 10:12:40 +00:00
parent c446bed0da
commit 1cb5b04d96
3 changed files with 78 additions and 20 deletions

View file

@ -1,37 +1,82 @@
.template_integration_otrs: &template_integration_otrs
allow_failure: true
extends:
- .template_integration
script:
- bundle exec rake zammad:db:unseeded
- bundle exec rails test test/integration/otrs_import_test.rb
variables:
FF_NETWORK_PER_BUILD: 1 # https://docs.gitlab.com/runner/configuration/feature-flags.html
IMPORT_OTRS_ENDPOINT: "http://zammad-ci-otrsimport-app/otrs/public.pl?Action=ZammadMigrator"
TZ: "Europe/Berlin" # Required for the zammad-ci-otrsimport-app containers
otrs:6:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "https://vz1185.test.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs6
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs6
alias: zammad-ci-otrsimport-app
otrs:5:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "http://vz1109.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs5
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs5
alias: zammad-ci-otrsimport-app
otrs:4:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "http://vz383.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs4
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs4
alias: zammad-ci-otrsimport-app
otrs:33:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs33
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs33
alias: zammad-ci-otrsimport-app
otrs:32:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "http://vz382.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs32
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs32
alias: zammad-ci-otrsimport-app
otrs:31:
<<: *template_integration_otrs
variables:
IMPORT_OTRS_ENDPOINT: "http://vz381.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
services:
- name: registry.znuny.com/docker/zammad-mysql:stable
alias: mysql
- name: registry.znuny.com/docker/zammad-postgresql:stable
alias: postgresql
- name: registry.znuny.com/docker/zammad-ci-otrsimport-db:otrs31
alias: zammad-ci-otrsimport-db
- name: registry.znuny.com/docker/zammad-ci-otrsimport-app:otrs31
alias: zammad-ci-otrsimport-app

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'yaml'
require 'resolv'
cnf = YAML.load_file(File.join(__dir__, '../../config/database/database.yml'))
@ -8,6 +9,7 @@ cnf.delete('default')
database = ENV['ENFORCE_DB_SERVICE']
# Lookup in /etc/hosts first: gitlab uses that if FF_NETWORK_PER_BUILD is not set.
if !database
hostsfile = '/etc/hosts'
database = %w[postgresql mysql].shuffle.find do |possible_database|
@ -15,7 +17,21 @@ if !database
end
end
raise "Can't find any supported database in #{hostsfile}." if database.nil?
# Lookup via DNS if needed: gitlab uses that if FF_NETWORK_PER_BUILD is enabled.
if !database
dns = Resolv::DNS.new
dns.timeouts = 3
database = %w[postgresql mysql].shuffle.find do |possible_database|
# Perform a lookup of the database host to check if it is configured as a service.
if dns.getaddress possible_database
next possible_database
end
rescue Resolv::ResolvError
# Ignore DNS lookup errors
end
end
raise "Can't find any supported database." if database.nil?
puts "NOTICE: Found/selected #{database} Database Service"

View file

@ -20,13 +20,10 @@ class OtrsImportTest < ActiveSupport::TestCase
# check settings items
test 'check settings' do
http = nil
system_id = nil
if ENV['IMPORT_OTRS_ENDPOINT'] =~ %r{^(http|https)://((.+?)\..+?)/}
if ENV['IMPORT_OTRS_ENDPOINT'] =~ %r{^(http|https)://}
http = $1
system_id = $3
system_id.gsub!(%r{[A-z]}, '') # strip chars
end
assert_equal( system_id, Setting.get('system_id'), 'system_id' )
assert( Setting.get('system_id'), 'system_id' )
assert_equal( http, Setting.get('http_type'), 'http_type' )
assert_equal( 'Example Company', Setting.get('organization'), 'organization' )
end