Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name conflicts #48

Merged
merged 3 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/beaker/hypervisor/google_compute.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
require 'time'
require 'securerandom'

module Beaker
# Beaker support for the Google Compute Engine.
class GoogleCompute < Beaker::Hypervisor
SLEEPWAIT = 5

# Hours before an instance is considered a zombie
ZOMBIE = 3

# Do some reasonable sleuthing on the SSH public key for GCE

##
Expand Down Expand Up @@ -87,8 +84,7 @@ def initialize(google_hosts, options)
# Create and configure virtual machines in the Google Compute Engine,
# including their associated disks and firewall rules
def provision
start = Time.now
test_group_identifier = "beaker-#{start.to_i}"
test_group_identifier = "beaker-#{SecureRandom.hex(4)}"

# set firewall to open pe ports
network = @gce_helper.get_network
Expand All @@ -97,15 +93,15 @@ def provision

# Always allow ssh from anywhere as it's needed for Beaker to run
@gce_helper.create_firewall(@external_firewall_name, network, allow: @options[:gce_ports] + ['22/tcp'], source_ranges: ['0.0.0.0/0'], target_tags: [test_group_identifier])

@logger.debug("Created External Google Compute firewall #{@external_firewall_name}")

# Create a firewall that opens everything between all the hosts in this test group
@internal_firewall_name = test_group_identifier + '-internal'
internal_ports = ['1-65535/tcp', '1-65535/udp', '-1/icmp']
@gce_helper.create_firewall(@internal_firewall_name, network, allow: internal_ports, source_tags: [test_group_identifier], target_tags: [test_group_identifier])
@logger.debug("Created test group Google Compute firewall #{@internal_firewall_name}")

@hosts.each do |host|
machine_type_name = ENV.fetch('BEAKER_gce_machine_type', host['gce_machine_type'])
raise "Must provide a machine type name in 'gce_machine_type'." if machine_type_name.nil?
Expand Down Expand Up @@ -194,7 +190,7 @@ def provision
value: 'FALSE'
},
]

# Check for google's default windows images and turn on ssh if found
if image_project == "windows-cloud" || image_project == "windows-sql-cloud"
# Turn on SSH on GCP's default windows images
Expand Down