File: setup.rb

package info (click to toggle)
capistrano 3.19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 804 kB
  • sloc: ruby: 5,351; makefile: 5
file content (91 lines) | stat: -rw-r--r-- 2,696 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
Given(/^a test app with the default configuration$/) do
  TestApp.install
end

Given(/^a test app without any configuration$/) do
  TestApp.create_test_app
end

Given(/^servers with the roles app and web$/) do
  start_ssh_server
  wait_for_ssh_server
end

Given(/^a linked file "(.*?)"$/) do |file|
  # ignoring other linked files
  TestApp.append_to_deploy_file("set :linked_files, ['#{file}']")
end

Given(/^file "(.*?)" exists in shared path$/) do |file|
  file_shared_path = TestApp.shared_path.join(file)
  run_remote_ssh_command("mkdir -p #{file_shared_path.dirname}")
  run_remote_ssh_command("touch #{file_shared_path}")
end

Given(/^all linked files exists in shared path$/) do
  TestApp.linked_files.each do |linked_file|
    step %Q{file "#{linked_file}" exists in shared path}
  end
end

Given(/^file "(.*?)" does not exist in shared path$/) do |file|
  file_shared_path = TestApp.shared_path.join(file)
  run_remote_ssh_command("mkdir -p #{TestApp.shared_path}")
  run_remote_ssh_command("touch #{file_shared_path} && rm #{file_shared_path}")
end

Given(/^a custom task to generate a file$/) do
  TestApp.copy_task_to_test_app("spec/support/tasks/database.rake")
end

Given(/^a task which executes as root$/) do
  TestApp.copy_task_to_test_app("spec/support/tasks/root.rake")
end

Given(/config stage file has line "(.*?)"/) do |line|
  TestApp.append_to_deploy_file(line)
end

Given(/^the configuration is in a custom location$/) do
  TestApp.move_configuration_to_custom_location("app")
end

Given(/^a custom task that will simulate a failure$/) do
  safely_remove_file(TestApp.shared_path.join("failed"))
  TestApp.copy_task_to_test_app("spec/support/tasks/fail.rake")
end

Given(/^a custom task to run in the event of a failure$/) do
  safely_remove_file(TestApp.shared_path.join("failed"))
  TestApp.copy_task_to_test_app("spec/support/tasks/failed.rake")
end

Given(/^a stage file named (.+)$/) do |filename|
  TestApp.write_local_stage_file(filename)
end

Given(/^I make (\d+) deployments?$/) do |count|
  step "all linked files exists in shared path"

  @release_paths = (1..count.to_i).map do
    TestApp.cap("deploy")
    stdout, _stderr = run_remote_ssh_command("readlink #{TestApp.current_path}")

    stdout.strip
  end
end

Given(/^(\d+) valid existing releases$/) do |num|
  a_day = 86_400 # in seconds
  (1...num).each_slice(100) do |num_batch|
    dirs = num_batch.map do |i|
      offset = -(a_day * i)
      TestApp.release_path(TestApp.timestamp(offset))
    end
    run_remote_ssh_command("mkdir -p #{dirs.join(' ')}")
  end
end

Given(/^an invalid release named "(.+)"$/) do |filename|
  run_remote_ssh_command("mkdir -p #{TestApp.release_path(filename)}")
end