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

Run test suite on PRs #51

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
31 changes: 31 additions & 0 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Spec tests

on:
push:
branches:
- main

pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
run_test_suite:
name: Run test suite
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Earthly
uses: earthly/actions-setup@v1
with:
version: 0.8.14

- name: Run tests
run: |
earthly config global.buildkit_max_parallelism 1
earthly -P ./test+test-autoinstall
earthly -P ./test+test
2 changes: 2 additions & 0 deletions test/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ test-autoinstall:
-e AUTO_RUN_INSTALLER=true \
-v /tmp/sim:/run/sim \
deskpro/docker-product-base:test web \
&& docker exec test /bin/sh -c '/usr/local/bin/is-ready --check-tasks --wait --timeout 60 -v' \
&& docker exec test /bin/sh -c 'cd /test/serverspec && rspec spec/scenarios/autoinstall/01_installer_spec.rb' \
&& docker stop test \
# second run - verify that the installer doesn't run again
Expand All @@ -105,6 +106,7 @@ test-automigrations:
-e AUTO_RUN_MIGRATIONS=true \
-v /tmp/sim:/run/sim \
deskpro/docker-product-base:test web \
&& docker exec test /bin/sh -c '/usr/local/bin/is-ready --check-tasks --wait --timeout 60 -v' \
&& docker exec test /bin/sh -c 'cd /test/serverspec && rspec spec/scenarios/automigrations/01_migrations_spec.rb' \
&& docker stop test \
# second run - verify that migrations doesn't run again
Expand Down
301 changes: 205 additions & 96 deletions test/serverspec/spec/always/paths_spec.rb
Original file line number Diff line number Diff line change
@@ -1,101 +1,210 @@
require 'spec_helper'

describe file('/etc/php/8.3') do
it { should exist }
it { should be_directory }
describe "Default file checks" do
before(:all) do
system('/usr/local/bin/is-ready --check-entrypoint --check-tasks --wait --timeout 60 -v') or raise "is-ready failed"
end

describe file('/etc/php/8.3') do
it { should exist }
it { should be_directory }
end

describe file('/usr/local/share/deskpro/container-var-reference.json') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content_as_json) { should_not be_empty }
end

describe file('/usr/local/share/deskpro/container-public-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-private-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-setenv-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/phpinfo.php') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/var/log/nginx') do
it { should be_directory }
it { should be_owned_by 'nginx' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/php') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/deskpro') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/lib/vector') do
it { should be_directory }
it { should be_owned_by 'vector' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA/deskpro-config.d') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/services/messenger-api/.env') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-var-reference.json') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content_as_json) { should_not be_empty }
end

describe file('/usr/local/share/deskpro/container-public-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-private-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-setenv-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/phpinfo.php') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/var/log/nginx') do
it { should be_directory }
it { should be_owned_by 'nginx' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/php') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/deskpro') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/lib/vector') do
it { should be_directory }
it { should be_owned_by 'vector' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA/deskpro-config.d') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end
end

describe file('/usr/local/share/deskpro/container-var-reference.json') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content_as_json) { should_not be_empty }
end

describe file('/usr/local/share/deskpro/container-public-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-private-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-setenv-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/container-var-list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/usr/local/share/deskpro/phpinfo.php') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/var/log/nginx') do
it { should be_directory }
it { should be_owned_by 'nginx' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/php') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/log/deskpro') do
it { should be_directory }
it { should be_owned_by 'dp_app' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/var/lib/vector') do
it { should be_directory }
it { should be_owned_by 'vector' }
it { should be_grouped_into 'adm' }

it { should be_readable.by('owner') }
it { should be_readable.by('group') }
it { should be_writable.by('owner') }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end

describe file('/srv/deskpro/INSTANCE_DATA/deskpro-config.d') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should_not be_writable.by('others') }
end
17 changes: 16 additions & 1 deletion test/serverspec/spec/default_web/utils/is-ready_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
FileUtils.touch('/run/container-ready')
FileUtils.remove_file('/run/container-running-installer', true)
FileUtils.remove_file('/run/container-running-migrations', true)
FileUtils.remove_file('/run/container-running-entrypoint', true)
end

it "Blocks when using --wait", :slow do
Expand Down Expand Up @@ -87,10 +88,24 @@
expect(exit_code).to eq 0
end

it "Post-boot tasks matter with --check-tasks" do
it "Post-boot migration tasks matter with --check-tasks" do
FileUtils.touch('/run/container-running-migrations')
system('is-ready --check-tasks')
exit_code = $?.exitstatus
expect(exit_code).to eq 1
end

it "Post-boot installer tasks matter with --check-tasks" do
FileUtils.touch('/run/container-running-installer')
system('is-ready --check-tasks')
exit_code = $?.exitstatus
expect(exit_code).to eq 1
end

it "Post-boot entrypoint tasks matter with --check-tasks" do
FileUtils.touch('/run/container-running-entrypoint')
system('is-ready --check-tasks')
exit_code = $?.exitstatus
expect(exit_code).to eq 1
end
end
Loading
Loading