File: stack_tests.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (128 lines) | stat: -rw-r--r-- 4,050 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
require "test_helper"
require 'fog/core'

describe "Fog::OpenStack::Orchestration | stack requests" do
  before do
    @oldcwd = Dir.pwd
    Dir.chdir("test/requests/orchestration")
    @base_url = "file://" + File.absolute_path(".")

    @orchestration = Fog::OpenStack::Orchestration.new

    @stack_mock = Fog::OpenStack::Orchestration::Stack.new(
      :template_name => "stack_mock",
      :id            => "stack_id"
    )

    @stack_format = {
      'links'               => Array,
      'id'                  => String,
      'stack_name'          => String,
      'description'         => Fog::Nullable::String,
      'stack_status'        => String,
      'stack_status_reason' => String,
      'creation_time'       => Time,
      'updated_time'        => Time
    }

    @stack_detailed_format = {
      "parent"                => Fog::Nullable::String,
      "disable_rollback"      => Fog::Boolean,
      "description"           => String,
      "links"                 => Array,
      "stack_status_reason"   => String,
      "stack_name"            => String,
      "stack_user_project_id" => String,
      "stack_owner"           => String,
      "creation_time"         => Fog::Nullable::String,
      "capabilities"          => Array,
      "notification_topics"   => Array,
      "updated_time"          => Fog::Nullable::String,
      "timeout_mins"          => Fog::Nullable::String,
      "stack_status"          => String,
      "parameters"            => Hash,
      "id"                    => String,
      "outputs"               => Array,
      "template_description"  => String
    }

    @create_format = {
      'id'    => String,
      'links' => Array,
    }

    @create_format_files = {
      'id'    => String,
      'links' => Array,
      'files' => Hash
    }
  end
  after do
    Dir.chdir(@oldcwd)
  end

  describe "success" do
    it "#create_stack" do
      @stack = @orchestration.create_stack(:stack_name => "teststack").body.must_match_schema(@create_format)
    end

    it "#create_stack_with_files" do
      args = {
        :stack_name => "teststack_files",
        :files      => {'foo.sh'=>'hello'}
      }
      @stack = @orchestration.create_stack(args).body.must_match_schema(@create_format_files)
    end

    it "#create_stack_resolve_files" do
      expected = prefix_with_url(["local.yaml", "hot_1.yaml"], @base_url)
      args = {
        :stack_name => "teststack_files",
        :template   => YAML.load_file("local.yaml"),
      }
      response = @orchestration.create_stack(args)
      response.body.must_match_schema(@create_format_files)
      files = response.body['files']
      Fog::Logger.warning("Request processed: #{files.keys}")
      assert_equal_set(expected, files.keys)
    end

    it "#create_stack_merge_files" do
      expected = prefix_with_url(["local.yaml", "hot_1.yaml", "file.txt"], @base_url)
      args = {
        :stack_name => "teststack_files",
        :template   => YAML.load_file("local.yaml"),
        :files      => {expected[-1] => "# just a mock"}
      }
      response = @orchestration.create_stack(args)
      response.body.must_match_schema(@create_format_files)
      files = response.body['files']
      Fog::Logger.warning("Request processed: #{files.keys}")
      assert_equal_set(expected, files.keys)
    end

    it "#list_stack_data" do
      @orchestration.list_stack_data.body.must_match_schema('stacks' => [@stack_format])
    end

    it "#list_stack_data_Detailed" do
      @orchestration.list_stack_data_detailed.body.must_match_schema('stacks' => [@stack_detailed_format])
    end

    it "#update_stack" do
      @orchestration.update_stack(@stack_mock).body.must_match_schema({})
    end

    it "#patch_stack" do
      @orchestration.patch_stack(@stack_mock).body.must_match_schema({})
    end

    it "#delete_stack" do
      @orchestration.delete_stack(@stack_mock).body.must_match_schema({})
    end

    it "#cancel_update" do
      @orchestration.cancel_update(@stack_mock).body.must_match_schema({})
    end
  end
end