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

Chore/sc 117667/upgrade node version for dp product #59

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
29 changes: 29 additions & 0 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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 -P ./test+test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ COPY --from=builder-php-exts /usr/lib/php/20230831/opentelemetry.so /usr/lib/php
COPY --from=hairyhenderson/gomplate:v3.11.5 /gomplate /usr/local/bin/gomplate
COPY --from=composer:2.5.8 /usr/bin/composer /usr/local/bin/composer
COPY --from=timberio/vector:0.39.0-debian /usr/bin/vector /usr/local/bin/vector
COPY --from=node:18.19-bookworm /usr/local/bin /usr/local/bin
COPY --from=node:18.19-bookworm /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node:20.16.0-bookworm /usr/local/bin /usr/local/bin
COPY --from=node:20.16.0-bookworm /usr/local/lib/node_modules /usr/local/lib/node_modules

RUN npm install --global tsx

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
6 changes: 6 additions & 0 deletions usr/local/bin/is-ready
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ check_ready() {
return 1
fi


if [ "$check_tasks" = "1" ]; then
if [ -f "/run/container-running-entrypoint" ]; then
output "Entrypoint initialisation is running"
return 1
fi

if [ -f "/run/container-running-installer" ]; then
output "Installer is running"
return 1
Expand Down
Loading
Loading