|
24 | 24 | end
|
25 | 25 |
|
26 | 26 | it 'creates a default VERSION file and restarts service' do
|
| 27 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).and_call_original |
| 28 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).with('gitlab-kas').and_return(true) |
27 | 29 | expect(chef_run).to create_version_file('Create version file for Gitlab KAS').with(
|
28 | 30 | version_file_path: '/var/opt/gitlab/gitlab-kas/VERSION',
|
29 | 31 | version_check_cmd: '/opt/gitlab/embedded/bin/gitlab-kas --version'
|
|
32 | 34 | expect(chef_run.version_file('Create version file for Gitlab KAS')).to notify('runit_service[gitlab-kas]').to(:restart)
|
33 | 35 | end
|
34 | 36 |
|
| 37 | + it 'creates a default VERSION file and does not restart the service if stopped' do |
| 38 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).and_call_original |
| 39 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).with('gitlab-kas').and_return(false) |
| 40 | + expect(chef_run).to create_version_file('Create version file for Gitlab KAS').with( |
| 41 | + version_file_path: '/var/opt/gitlab/gitlab-kas/VERSION', |
| 42 | + version_check_cmd: '/opt/gitlab/embedded/bin/gitlab-kas --version' |
| 43 | + ) |
| 44 | + |
| 45 | + expect(chef_run.version_file('Create version file for Gitlab KAS')).to_not notify('runit_service[gitlab-kas]').to(:restart) |
| 46 | + end |
| 47 | + |
35 | 48 | it 'correctly renders the KAS service run file' do
|
36 | 49 | expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-kas/run").with_content(%r{--configuration-file /var/opt/gitlab/gitlab-kas/gitlab-kas-config.yml})
|
37 | 50 | end
|
|
636 | 649 | end
|
637 | 650 | end
|
638 | 651 |
|
| 652 | + describe 'chef_run.file calls' do |
| 653 | + def files |
| 654 | + @files ||= %w( |
| 655 | + /var/opt/gitlab/gitlab-kas/authentication_secret_file |
| 656 | + /var/opt/gitlab/gitlab-kas/private_api_authentication_secret_file |
| 657 | + /var/opt/gitlab/gitlab-kas/redis_password_file |
| 658 | + /var/opt/gitlab/gitlab-kas/redis_sentinels_password_file |
| 659 | + ) |
| 660 | + end |
| 661 | + |
| 662 | + before do |
| 663 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).and_call_original |
| 664 | + end |
| 665 | + |
| 666 | + context "when omnibus_helper.should_notify?('gitlab-kas') returns true" do |
| 667 | + before do |
| 668 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).with('gitlab-kas').and_return(true) |
| 669 | + end |
| 670 | + |
| 671 | + it 'chef_run.file calls notify gitlab-kas to restart' do |
| 672 | + files.each do |file| |
| 673 | + expect(chef_run.file(file)).to notify('runit_service[gitlab-kas]').to(:restart) |
| 674 | + end |
| 675 | + end |
| 676 | + end |
| 677 | + |
| 678 | + context "when omnibus_helper.should_notify?('gitlab-kas') returns false" do |
| 679 | + before do |
| 680 | + allow_any_instance_of(OmnibusHelper).to receive(:should_notify?).with('gitlab-kas').and_return(false) |
| 681 | + end |
| 682 | + |
| 683 | + it 'chef_run.file calls do not notify gitlab-kas to restart' do |
| 684 | + files.each do |file| |
| 685 | + expect(chef_run.file(file)).to_not notify('runit_service[gitlab-kas]').to(:restart) |
| 686 | + end |
| 687 | + end |
| 688 | + end |
| 689 | + end |
| 690 | + |
639 | 691 | def chef_run_load_yaml_template(chef_run, path)
|
640 | 692 | template = chef_run.template(path)
|
641 | 693 | file_content = ChefSpec::Renderer.new(chef_run, template).content
|
|
0 commit comments