Skip to content

Commit fb12a51

Browse files
authored
DOC-1455 End to end config property automation (#129)
* Add support for overrides and proper defaults * Add support for providing examples in overrides * Add support for overriding version * Add support for templates * Apply suggestions * Update directories for output files * Do not add name field * Fix test * Save only final properties to examples dir * Remove duplicates * Bump version * Improve error reporting * Increase timeout * Mock data for faster testing * Simplify * Apply suggestions * Allow for null defaults * Fix dirs * Apply suggestions * Update tools/property-extractor/generate-handlebars-docs.js * Update deprecated * Fix doc * Integrate topic property automation * Bump version
1 parent abb5b14 commit fb12a51

31 files changed

+2465
-620
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,6 @@ jobs:
222222
- name: Run all tests
223223
run: npm test
224224

225-
- name: Generate coverage report
226-
if: matrix.node-version == '18'
227-
run: npm test -- --coverage --coverageReporters=lcov
228-
229-
- name: Upload coverage to Codecov
230-
if: matrix.node-version == '18'
231-
uses: codecov/codecov-action@v3
232-
with:
233-
token: ${{ secrets.CODECOV_TOKEN }}
234-
file: ./coverage/lcov.info
235-
flags: unittests
236-
name: codecov-umbrella
237-
238225
# Summary job that all other jobs depend on
239226
test-summary:
240227
if: always()

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/node_modules/*
21
/wip/*
32
/docs/*
43
.vscode
@@ -10,4 +9,5 @@ gen/
109
tree-sitter/
1110
test/
1211
modules/
13-
cloud-controlplane/
12+
cloud-controlplane/
13+
node_modules
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.Example Configuration for Admin API
2+
This example shows how to configure the admin API endpoint with custom addressing.
3+
4+
[,yaml]
5+
----
6+
redpanda:
7+
admin:
8+
- address: "0.0.0.0"
9+
port: 9644
10+
- address: "127.0.0.1"
11+
port: 9645
12+
----
13+
14+
You can specify multiple admin endpoints to provide redundancy and load balancing.
15+
The admin API is used for cluster management operations.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"properties": {
3+
"admin": {
4+
"description": "Network addresses for Admin API servers with version info.",
5+
"version": "v23.1.0",
6+
"example_file": "examples/admin-example.adoc"
7+
},
8+
"admin_api_tls": {
9+
"description": "TLS configuration for the Admin API endpoints.",
10+
"version": "v23.2.0",
11+
"example_yaml": {
12+
"title": "Example TLS Configuration",
13+
"description": "This example shows how to configure TLS for the Admin API with client authentication.",
14+
"config": {
15+
"redpanda": {
16+
"admin_api_tls": [
17+
{
18+
"name": "internal-admin",
19+
"enabled": true,
20+
"cert_file": "/etc/redpanda/certs/admin.crt",
21+
"key_file": "/etc/redpanda/certs/admin.key",
22+
"truststore_file": "/etc/redpanda/certs/ca.crt",
23+
"require_client_auth": true
24+
}
25+
]
26+
}
27+
}
28+
}
29+
},
30+
"abort_index_segment_size": {
31+
"description": "Segment size for transaction abort index. Controls how large each abort index segment can grow.",
32+
"example": [
33+
".Example: Setting abort index segment size",
34+
"[,yaml]",
35+
"----",
36+
"redpanda:",
37+
" abort_index_segment_size: 134217728 # 128MB",
38+
"----",
39+
"",
40+
"This setting controls the maximum size of abort index segments.",
41+
"Smaller segments may improve memory usage but increase overhead."
42+
]
43+
},
44+
"append_chunk_size": {
45+
"description": "Size of data chunks for append operations.",
46+
"version": "v24.1.0",
47+
"example": "67108864"
48+
},
49+
"cloud_storage_access_key": {
50+
"description": "Access key for cloud storage authentication. Used to authenticate with S3-compatible object storage services."
51+
},
52+
"cleanup.policy": {
53+
"description": "Determines how log segments are cleaned. **delete** removes old segments based on time or size. **compact** retains only the latest value for each key. **compact,delete** enables both strategies.",
54+
"version": "v23.1.0",
55+
"example": [
56+
".Example: Setting cleanup policy",
57+
"[,bash]",
58+
"----",
59+
"rpk topic alter-config my-topic --set cleanup.policy=compact",
60+
"----",
61+
"",
62+
"For topics that require both compaction and deletion:",
63+
"",
64+
"[,bash]",
65+
"----",
66+
"rpk topic alter-config my-topic --set cleanup.policy=compact,delete",
67+
"----"
68+
]
69+
},
70+
"compression.type": {
71+
"description": "Compression algorithm used for compressing message batches. Options include **none** (no compression), **gzip**, **snappy**, **lz4**, and **zstd**.",
72+
"example": [
73+
".Example: Setting compression type",
74+
"[,bash]",
75+
"----",
76+
"rpk topic alter-config my-topic --set compression.type=zstd",
77+
"----"
78+
]
79+
}
80+
}
81+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const os = require('os');
4+
5+
const repoRoot = path.resolve(__dirname, '..', '..');
6+
const overridesFile = path.join(repoRoot, '__tests__', 'docs-data', 'property-overrides.json');
7+
8+
describe('property-docs description override', () => {
9+
let tempDir;
10+
let mockPropertiesFile;
11+
12+
beforeAll(() => {
13+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'property-docs-test-'));
14+
15+
// Create mock property data that includes admin property
16+
const mockProperties = {
17+
properties: {
18+
admin: {
19+
config_scope: "broker",
20+
default: [{ address: "127.0.0.1", port: 9644 }],
21+
defined_in: "src/v/config/node_config.cc",
22+
description: "Default description for admin",
23+
name: "admin",
24+
needs_restart: true,
25+
nullable: false,
26+
type: "array",
27+
visibility: "user"
28+
},
29+
kafka_api: {
30+
config_scope: "broker",
31+
default: [{ address: "127.0.0.1", port: 9092 }],
32+
defined_in: "src/v/config/node_config.cc",
33+
description: "IP address and port of the Kafka API endpoint that handles requests.",
34+
name: "kafka_api",
35+
needs_restart: true,
36+
nullable: false,
37+
type: "array",
38+
visibility: "user"
39+
}
40+
}
41+
};
42+
43+
// Write mock properties to a temp file
44+
mockPropertiesFile = path.join(tempDir, 'mock-properties.json');
45+
fs.writeFileSync(mockPropertiesFile, JSON.stringify(mockProperties, null, 2));
46+
});
47+
48+
afterAll(() => {
49+
fs.rmSync(tempDir, { recursive: true, force: true });
50+
});
51+
52+
it('applies the override description for admin property', () => {
53+
const overrides = JSON.parse(fs.readFileSync(overridesFile, 'utf8'));
54+
const mockProperties = JSON.parse(fs.readFileSync(mockPropertiesFile, 'utf8'));
55+
56+
// Test 1: Verify the override file structure
57+
const adminOverride = overrides.properties.admin;
58+
expect(adminOverride).toBeTruthy();
59+
expect(adminOverride.description).toBeTruthy();
60+
expect(adminOverride.version).toBe('v23.1.0');
61+
expect(adminOverride.description).toBe('Network addresses for Admin API servers with version info.');
62+
63+
// Test 2: Verify our mock data has the correct structure (no artificial name field)
64+
const adminProperty = mockProperties.properties.admin;
65+
expect(adminProperty.default).toEqual([{ address: "127.0.0.1", port: 9644 }]);
66+
67+
const adminDefault = adminProperty.default[0];
68+
expect(adminDefault).toHaveProperty('address', '127.0.0.1');
69+
expect(adminDefault).toHaveProperty('port', 9644);
70+
71+
// Test 3: Simulate applying overrides (this is what the Python script would do)
72+
const adminWithOverrides = {
73+
...adminProperty,
74+
description: adminOverride.description,
75+
version: adminOverride.version
76+
};
77+
78+
expect(adminWithOverrides.description).toBe('Network addresses for Admin API servers with version info.');
79+
expect(adminWithOverrides.version).toBe('v23.1.0');
80+
expect(adminWithOverrides.default).toEqual([{ address: "127.0.0.1", port: 9644 }]);
81+
82+
// Test 4: Verify that kafka_api (without overrides) keeps its original description
83+
const kafkaProperty = mockProperties.properties.kafka_api;
84+
expect(kafkaProperty.description).toBe('IP address and port of the Kafka API endpoint that handles requests.');
85+
expect(kafkaProperty.default).toEqual([{ address: "127.0.0.1", port: 9092 }]);
86+
});
87+
});

0 commit comments

Comments
 (0)