File: mount_target_tests.rb

package info (click to toggle)
ruby-fog-aws 3.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,140 kB
  • sloc: ruby: 73,328; javascript: 14; makefile: 9; sh: 4
file content (45 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Shindo.tests("AWS::EFS | mount target", ["aws", "efs"]) do
  @file_system = Fog::AWS[:efs].file_systems.create(:creation_token => "fogtoken#{rand(999).to_s}")
  @file_system.wait_for { ready? }

  if Fog.mocking?
    vpc = Fog::Compute[:aws].vpcs.create(:cidr_block => "10.0.0.0/16")
    subnet = Fog::Compute[:aws].subnets.create(:vpc_id => vpc.id, :cidr_block => "10.0.1.0/24")
    default_security_group_data = Fog::Compute[:aws].data[:security_groups].values.find do |sg|
      sg['groupDescription'] == 'default_elb security group'
    end
    default_security_group = Fog::Compute[:aws].security_groups.new(default_security_group_data)
  else
    vpc = Fog::Compute[:aws].vpcs.first
    subnet = vpc.subnets.first
    default_security_group = Fog::Compute[:aws].security_groups.detect { |sg| sg.description == 'default VPC security group' }
  end

  security_group = Fog::Compute[:aws].security_groups.create(
    :vpc_id      => vpc.id,
    :name        => "fog#{rand(999).to_s}",
    :description => "fog#{rand(999).to_s}"
  )

  mount_target_params = {
    :file_system_id  => @file_system.identity,
    :subnet_id       => subnet.identity,
  }

  model_tests(Fog::AWS[:efs].mount_targets, mount_target_params, true) do
    @instance.wait_for { ready? }

    tests("#security_groups") do
      returns([default_security_group.group_id]) { @instance.security_groups }
    end

    tests("#security_groups=") do
      @instance.security_groups = [security_group.group_id]
      returns([security_group.group_id]) { @instance.security_groups }
    end
  end

  @file_system.wait_for { number_of_mount_targets == 0 }
  @file_system.destroy
  security_group.destroy
end