Skip to content

Commit

Permalink
Maintenance: switch to Docker based OTRS import testing rather than u…
Browse files Browse the repository at this point in the history
…sing external services.
  • Loading branch information
mgruner committed Jun 16, 2021
1 parent c446bed commit 1cb5b04
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 20 deletions.
71 changes: 58 additions & 13 deletions .gitlab/ci/integration/otrs.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 17 additions & 1 deletion script/build/database_config.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# 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'))

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|
File.foreach(hostsfile).any? { |l| l[possible_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"

Expand Down
9 changes: 3 additions & 6 deletions test/integration/otrs_import_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)://((.+?)\..+?)/}
http = $1
system_id = $3
system_id.gsub!(%r{[A-z]}, '') # strip chars
if ENV['IMPORT_OTRS_ENDPOINT'] =~ %r{^(http|https)://}
http = $1
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
Expand Down

0 comments on commit 1cb5b04

Please sign in to comment.