Skip to content

Commit f5d9bff

Browse files
committed
test: a tmp test for this branch to test older versions
1 parent 4b3970a commit f5d9bff

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/testinfra-ami-build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ jobs:
9494
sudo rm -rf /tmp/* # Clean temporary files
9595
df -h / # Display available space
9696
97+
- name: Patch stage2-nix-psql.pkr.hcl to create pg_extensions.json
98+
run: |
99+
cat >> stage2-nix-psql.pkr.hcl << 'EOF'
100+
# Add provisioner to create pg_extensions.json
101+
provisioner "shell" {
102+
inline = [
103+
"echo '{\"pg_cron\":\"1.3.1\"}' | sudo tee /root/pg_extensions.json",
104+
"sudo chmod 644 /root/pg_extensions.json",
105+
"echo 'Created pg_extensions.json with content:' && sudo cat /root/pg_extensions.json"
106+
]
107+
}
108+
EOF
109+
# Display the modified file to verify
110+
echo "Modified stage2-nix-psql.pkr.hcl:"
111+
tail -n 10 stage2-nix-psql.pkr.hcl
112+
97113
- name: Build AMI stage 2
98114
run: |
99115
packer init stage2-nix-psql.pkr.hcl

testinfra/test_ami_nix.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,3 +507,27 @@ def test_postgrest_ending_empty_key_query_parameter_is_removed(host):
507507
},
508508
)
509509
assert res.ok
510+
511+
512+
def test_pg_cron_extension(host):
513+
# Connect as supabase_admin and create the extension
514+
with host.sudo("postgres"):
515+
result = host.run('psql -U supabase_admin -d postgres -c "CREATE EXTENSION pg_cron WITH SCHEMA pg_catalog VERSION \'1.3.1\';"')
516+
assert result.rc == 0, f"Failed to create pg_cron extension: {result.stderr}"
517+
518+
# Create test table
519+
result = host.run('psql -U supabase_admin -d postgres -c "CREATE TABLE cron_test_log (id SERIAL PRIMARY KEY, message TEXT, log_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP);"')
520+
assert result.rc == 0, f"Failed to create test table: {result.stderr}"
521+
522+
# Schedule a job
523+
result = host.run('psql -U supabase_admin -d postgres -c "SELECT cron.schedule(\'* * * * *\', \'INSERT INTO cron_test_log (message) VALUES (\\\'Hello from pg_cron!\\\');\');"')
524+
assert result.rc == 0, f"Failed to schedule job: {result.stderr}"
525+
assert "1" in result.stdout, "Expected schedule ID 1"
526+
527+
# Verify job is scheduled
528+
result = host.run('psql -U supabase_admin -d postgres -c "SELECT * FROM cron.job;"')
529+
assert result.rc == 0, f"Failed to query cron.job: {result.stderr}"
530+
assert "* * * * *" in result.stdout, "Expected cron schedule pattern"
531+
assert "INSERT INTO cron_test_log" in result.stdout, "Expected cron command"
532+
assert "postgres" in result.stdout, "Expected postgres username"
533+
assert "postgres" in result.stdout, "Expected postgres database"

0 commit comments

Comments
 (0)