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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ python3 src/slurm_schema.py --output schema.json
The resulting `schema.json` file can be compared with the list of
tables and columns from your deployment.

### Testing with sample SlurmDB data

For unit tests and local development the repository includes two fixtures
under `test/`:

- `example_slurm_schema_for_testing.json` – a pre-generated mapping of
tables to columns for a minimal Slurm accounting database.
- `example_slurmdb_for_testing.sql` – a small SQL dump containing the
corresponding table definitions and a few dummy rows.

These files allow tests to verify table and column presence and operate on
sample data without requiring access to a live SlurmDB instance.

## 📝 Development Notes

- Your UI components can access system files or commands using `cockpit.file()` and other Cockpit APIs.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/slurm_schema_dump.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class SlurmSchemaDumpTests(unittest.TestCase):
def test_job_table_uses_cpus_req(self):
schema = extract_schema_from_dump('test/test_db_dump.sql')
schema = extract_schema_from_dump('test/example_slurmdb_for_testing.sql')
cols = schema.get('localcluster_job_table', [])
self.assertIn('cpus_req', cols)
self.assertNotIn('cpus_alloc', cols)
Expand Down
6 changes: 4 additions & 2 deletions test/unit/slurmdb_validation.test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import json
from slurmdb import SlurmDB
from slurm_schema import extract_schema_from_dump, extract_schema
from slurm_schema import extract_schema

class SlurmDBValidationTests(unittest.TestCase):
def test_invalid_cluster_rejected(self):
Expand Down Expand Up @@ -150,7 +151,8 @@ def fake_connect():
self.assertIsNone(db._conn)

def test_fetch_usage_records_uses_cpus_req_if_alloc_missing(self):
schema = extract_schema_from_dump('test/test_db_dump.sql')
with open('test/example_slurm_schema_for_testing.json') as fh:
schema = json.load(fh)
job_cols = schema.get('localcluster_job_table', [])

class FakeCursor:
Expand Down
Loading