Skip to content
Merged
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
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: release


"on":
push:
branches:
- main
branches: [main]

permissions:
contents: write
Expand All @@ -16,8 +16,10 @@ permissions:

jobs:
release:
uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@5.0.8
uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@main
secrets:
token: ${{ secrets.PORTER_GITHUB_TOKEN }}
supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }}
supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }}
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
_.path = "/opt/chef-workstation/bin"
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require:
- cookstyle
126 changes: 126 additions & 0 deletions .windsurf/workflows/kitchen-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
description: Run all kitchen suites and fix failures iteratively
auto_execution_mode: 3
---

# Kitchen Test and Fix Workflow

This workflow runs all Test Kitchen suites, aggregates failures, and iteratively fixes common issues.

## Steps

### 1. Get Your Bearings

Run `kitchen list` to see all available test suites and their current state.

```bash
chef exec kitchen list
```

Review the output to understand:

- Which suites exist (installer-mysql, installer-postgresql, standalone-mysql, standalone-postgresql)
- Which platforms are configured
- Current state of any existing instances

### 2. Run Kitchen Tests

Run all kitchen tests in parallel with destroy on completion:

```bash
# Run a single suite first to validate
chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always

# Or run all tests (this takes a long time)
chef exec kitchen test --concurrency=4 --destroy=always
```

For faster iteration, test one platform per suite first:

```bash
chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always
chef exec kitchen test installer-postgresql-ubuntu-2404 --destroy=always
chef exec kitchen test standalone-mysql-ubuntu-2404 --destroy=always
chef exec kitchen test standalone-postgresql-ubuntu-2404 --destroy=always
```

### 3. Aggregate Failures

When tests fail, collect and categorize the errors:

1. **Converge failures** - Recipe compilation or resource execution errors
2. **Verify failures** - InSpec/Serverspec test failures
3. **Platform-specific failures** - Issues only on certain OS families

For each failure, note:

- Suite name
- Platform
- Error message
- Stack trace location

### 4. Apply Common Fixes

Address failures by category:

#### Converge Failures

- Check recipe syntax and resource availability
- Verify cookbook dependencies in `metadata.rb` and `Berksfile`
- Review attribute precedence issues
- Check for deprecated Chef APIs

#### Verify Failures

- Review test expectations in `test/integration/*/serverspec/`
- Ensure services are running and ports are listening
- Check file permissions and ownership

#### Platform-Specific Failures

- Add platform conditionals where needed
- Check package names differ between distros
- Verify service names (systemd vs init)

### 5. Iterate

After applying fixes:

// turbo

1. Re-run the failing tests:

```bash
chef exec kitchen test <suite-platform> --destroy=always
```

1. If new failures appear, return to step 3
2. Continue until all tests pass

### 6. Verify All Suites Pass

Once individual fixes are applied, run the full test matrix:

```bash
chef exec kitchen test --concurrency=4 --destroy=always
```

### 7. Cleanup

Destroy any remaining kitchen instances:

// turbo

```bash
chef exec kitchen destroy
```

## Common Issues Reference

| Error | Cause | Fix |
|-----------------------|---------------------------------|---------------------------------|
| `undefined method` | Missing cookbook dependency | Add to `metadata.rb` depends |
| `package not found` | Wrong package name for platform | Use platform conditionals |
| `service not running` | Service failed to start | Check logs, add retries |
| `port not listening` | App not configured correctly | Review configuration templates |
| `Chef::Platform.set` | Deprecated API in dependency | Update cookbook version or stub |
70 changes: 55 additions & 15 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ suites:
- name: client
run_list:
- recipe[sql_server::default]
attributes: {sql_server: {accept_eula: true}}
attributes: { sql_server: { accept_eula: true } }
verifier:
controls:
- client
- name: server2012
run_list:
- recipe[sql_server::server]
attributes: {sql_server: {accept_eula: true, version: 2012, server_sa_password: Supersecurepassword123}}
verifier:
controls:
- server
inputs:
version: 2012
- name: server2016
run_list:
- recipe[sql_server::server]
attributes: {sql_server: {accept_eula: true, version: 2016, server_sa_password: Supersecurepassword123}}
attributes:
{
sql_server:
{
accept_eula: true,
version: 2016,
server_sa_password: Supersecurepassword123,
},
}
verifier:
controls:
- server
Expand All @@ -60,7 +59,15 @@ suites:
- name: server2017
run_list:
- recipe[sql_server::server]
attributes: {sql_server: {accept_eula: true, version: 2017, server_sa_password: Supersecurepassword123}}
attributes:
{
sql_server:
{
accept_eula: true,
version: 2017,
server_sa_password: Supersecurepassword123,
},
}
verifier:
controls:
- server
Expand All @@ -69,7 +76,15 @@ suites:
- name: server2019
run_list:
- recipe[sql_server::server]
attributes: {sql_server: {accept_eula: true, version: 2019, server_sa_password: Supersecurepassword123}}
attributes:
{
sql_server:
{
accept_eula: true,
version: 2019,
server_sa_password: Supersecurepassword123,
},
}
verifier:
controls:
- server
Expand All @@ -78,12 +93,37 @@ suites:
includes:
- windows-2016
- windows-2019
- name: server2022
run_list:
- recipe[sql_server::server]
attributes:
{
sql_server:
{
accept_eula: true,
version: 2022,
server_sa_password: Supersecurepassword123,
},
}
verifier:
controls:
- server
inputs:
version: 2022
- name: install
run_list:
- recipe[test::install]
verifier:
controls:
- server
inputs:
version: 2012
attributes: {sql_server: {accept_eula: true, version: 2012, server_sa_password: Supersecurepassword123}}
version: 2022
attributes:
{
sql_server:
{
accept_eula: true,
version: 2022,
server_sa_password: Supersecurepassword123,
},
}
10 changes: 10 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pre-commit:
commands:
cookstyle:
run: chef exec cookstyle
rspec:
run: chef exec rspec
yamllint:
run: yamllint .
markdownlint:
run: markdownlint-cli2 "**/*.md" --fix
69 changes: 26 additions & 43 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@ module Helper

def self.reg_version_string(version)
case version.to_s # to_s to make sure someone didn't pass us an int
when '2012' then 'MSSQL11.'
when '2016' then 'MSSQL13.'
when '2017' then 'MSSQL14.'
when '2019' then 'MSSQL15.'
when '2022' then 'MSSQL16.'
when '2025' then 'MSSQL17.'
else raise "Unsupported sql_server version '#{version}'. Please open a PR to add support for this version."
else raise "Unsupported sql_server version '#{version}'. Supported versions: 2016, 2017, 2019, 2022, 2025"
end
end

def self.install_dir_version(version)
case version.to_s # to_s to make sure someone didn't pass us an int
when '2012' then '110'
when '2016' then '130'
when '2017' then '140'
when '2019' then '150'
when '2022' then '160'
when '2025' then '170'
else raise "SQL Server version #{version} not supported. Please open a PR to add support for this version."
else raise "SQL Server version #{version} not supported. Supported versions: 2016, 2017, 2019, 2022, 2025"
end
end

Expand All @@ -54,53 +52,38 @@ def self.firewall_rule_enabled?(rule_name = nil)
end

def self.sql_server_url(version, x86_64)
if x86_64
case version.to_s # to_s to make sure someone didn't pass us an int
when '2012' then 'https://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPR_x64_ENU.exe'
when '2016' then 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe'
when '2017' then 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe'
when '2019' then 'https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe'
when '2022' then 'https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe'
when '2025' then 'https://download.microsoft.com/download/7ab8f535-7eb8-4b16-82eb-eca0fa2d38f3/SQL2025-SSEI-Expr.exe'
end
else
case version.to_s
when '2012' then 'https://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x86/SQLEXPR_x86_ENU.exe'
end
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions

case version.to_s # to_s to make sure someone didn't pass us an int
when '2016' then 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe'
when '2017' then 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe'
when '2019' then 'https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe'
when '2022' then 'https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe'
when '2025' then nil # URL not yet available - use source_url property
end
end

def self.sql_server_package_name(version, x86_64)
if x86_64
case version.to_s # to_s to make sure someone didn't pass us an int
when '2012' then 'Microsoft SQL Server 2012 (64-bit)'
when '2016' then 'Microsoft SQL Server 2016 (64-bit)'
when '2017' then 'Microsoft SQL Server 2017 (64-bit)'
when '2019' then 'Microsoft SQL Server 2019 (64-bit)'
when '2022' then 'Microsoft SQL Server 2022 (64-bit)'
when '2025' then 'Microsoft SQL Server 2025 (64-bit)'
end
else
case version.to_s
when '2012' then 'Microsoft SQL Server 2012 (32-bit)'
end
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions

case version.to_s # to_s to make sure someone didn't pass us an int
when '2016' then 'Microsoft SQL Server 2016 (64-bit)'
when '2017' then 'Microsoft SQL Server 2017 (64-bit)'
when '2019' then 'Microsoft SQL Server 2019 (64-bit)'
when '2022' then 'Microsoft SQL Server 2022 (64-bit)'
when '2025' then 'Microsoft SQL Server 2025 (64-bit)'
end
end

def self.sql_server_checksum(version, x86_64)
if x86_64
case version.to_s # to_s to make sure someone didn't pass us an int
when '2012' then '7f5e3d40b85fba2da5093e3621435c209c4ac90d34219bab8878e93a787cf29f'
when '2016' then '2A5B64AE64A8285C024870EC4643617AC5146894DD59DD560E75CEA787BF9333'
when '2017' then 'F857FF82145E196BF85AF32EEB0193FE38302E57B30BEB54E513630C60D83E0D'
when '2019' then 'bea033e778048748eb1c87bf57597f7f5449b6a15bac55ddc08263c57f7a1ca8'
when '2022' then '36e0ec2ac3dd60f496c99ce44722c629209ea7302a2ce9cbfd1e42a73510d7b6'
when '2025' then '1c677a33b318481c3217128835f8405cf0026621dcd04b13eb6cb0982e823f27'
end
else
case version.to_s
when '2012' then '9bdd6a7be59c00b0201519b9075601b1c18ad32a3a166d788f3416b15206d6f5'
end
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions

case version.to_s # to_s to make sure someone didn't pass us an int
when '2016' then '2A5B64AE64A8285C024870EC4643617AC5146894DD59DD560E75CEA787BF9333'
when '2017' then 'F857FF82145E196BF85AF32EEB0193FE38302E57B30BEB54E513630C60D83E0D'
when '2019' then 'bea033e778048748eb1c87bf57597f7f5449b6a15bac55ddc08263c57f7a1ca8'
when '2022' then '36e0ec2ac3dd60f496c99ce44722c629209ea7302a2ce9cbfd1e42a73510d7b6'
when '2025' then nil # Checksum not yet available - use package_checksum property
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion resources/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
unified_mode true

property :reg_version, String
property :version, [Integer, String], default: '2012'
property :version, [Integer, String], default: '2022'
property :tcp_enabled, [true, false], default: true
property :sql_port, Integer, default: 1433
property :tcp_dynamic_ports, String, default: ''
Expand Down
Loading
Loading