From 9b135974dbfc83dc53ac5e52433044b5059d58ba Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Wed, 1 Mar 2023 12:58:02 +0100 Subject: [PATCH] set flack for container_2_container --- .github/workflows/test.yml | 18 ++++++++++++++++++ .gitignore | 1 + .rubocop_todo.yml | 11 ++--------- Rakefile | 3 +-- lib/beaker/hypervisor/docker.rb | 7 ++++--- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94b493c..a2ecdc1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,6 +85,24 @@ jobs: - name: Run acceptance tests run: bundle exec rake test:acceptance + beaker_in_container: + runs-on: ubuntu-latest + name: Docker - Beaker in container connection test + steps: + - uses: actions/checkout@v3 + # use this and not container key from gha to not have a docker network from github + - name: Run Beaker in docker container + uses: addnab/docker-run-action@v3 + with: + image: puppet/puppet-dev-tools:2023-02-24-1bca42e + options: -v ${{ github.workspace }}:/work + run: | + cd /work + ls -la + bundle install + export DOCKER_IN_DOCKER=true + bundle exec rake test:acceptance + podman: runs-on: ubuntu-latest strategy: diff --git a/.gitignore b/.gitignore index d3deae5..a0413b5 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ doc # Vagrant folder .vagrant/ .vagrant_files/ +vendor/bundle diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b6d5d74..26b57a0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-12-21 18:24:52 UTC using RuboCop version 1.12.1. +# on 2023-03-03 13:24:13 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -541,13 +541,6 @@ Style/GuardClause: Exclude: - 'lib/beaker/hypervisor/docker.rb' -# Offense count: 39 -# Cop supports --auto-correct. -# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - EnforcedStyle: hash_rockets - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowIfModifier. @@ -690,7 +683,7 @@ Style/StringConcatenation: - 'lib/beaker/hypervisor/docker.rb' - 'spec/spec_helper.rb' -# Offense count: 66 +# Offense count: 64 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes diff --git a/Rakefile b/Rakefile index 7195da7..7e4d5fd 100644 --- a/Rakefile +++ b/Rakefile @@ -38,9 +38,8 @@ A quick acceptance test, named because it has no pre-suites to run beaker_test_base_dir = File.join(beaker_gem_dir, 'acceptance/tests/base') load_path_option = File.join(beaker_gem_dir, 'acceptance/lib') - ENV['BEAKER_setfile'] = 'acceptance/config/nodes/hosts.yaml' + ENV['BEAKER_setfile'] = 'acceptance/config/nodes/hosts.yaml' unless ENV.key?('BEAKER_setfile') sh("beaker", - "--hosts", "acceptance/config/nodes/hosts.yaml", # We can't run these tests until the rsync support in the main # beaker/host.rb is updated to work with passwords. # "--tests", beaker_test_base_dir, diff --git a/lib/beaker/hypervisor/docker.rb b/lib/beaker/hypervisor/docker.rb index 1e17964..12febe5 100644 --- a/lib/beaker/hypervisor/docker.rb +++ b/lib/beaker/hypervisor/docker.rb @@ -142,9 +142,9 @@ def get_ssh_connection_info(container) port: nil } - container_json = container.json + container_json = container.json network_settings = container_json['NetworkSettings'] - host_config = container_json['HostConfig'] + host_config = container_json['HostConfig'] ip = nil port = nil @@ -161,9 +161,10 @@ def get_ssh_connection_info(container) # Host to Container port22 = network_settings.dig('PortBindings','22/tcp') - if port22.nil? && network_settings.key?('Ports') + if port22.nil? && network_settings.key?('Ports') && !nested_docker? port22 = network_settings.dig('Ports','22/tcp') end + ip = port22[0]['HostIp'] if port22 port = port22[0]['HostPort'] if port22