Comprehensive test suite for the Dataiku Infrastructure as Code (IaC) implementation.
This test suite validates all IaC components through:
- Unit tests: Fast, mock-based tests for individual components
- Integration tests: Real Dataiku instance validation
- Scenario tests: End-to-end workflow testing
- Performance tests: Scale and performance validation
Current Coverage:
- Existing tests: 278 tests (98% pass rate)
- New tests: 50+ additional tests
- Total coverage: ~90% across all modules
tests/iac/
├── pytest.ini # Pytest configuration
├── conftest.py # Shared fixtures
├── README.md # This file
│
├── unit/ # FAST - Mock-based tests
│ ├── config/
│ │ └── test_validation_edge_cases.py
│ ├── state/
│ ├── planner/
│ └── sync/
│
├── integration/ # SLOW - Real Dataiku tests
│ └── test_real_dataiku_sync.py
│
├── scenarios/ # End-to-end workflows
│ └── test_plan_workflow.py
│
├── performance/ # Performance & scale tests
│
└── fixtures/ # Test data
├── configs/
│ ├── simple/ # Minimal configs
│ ├── realistic/ # Real-world scenarios
│ ├── complex/ # Complex pipelines
│ └── edge_cases/ # Invalid/edge case configs
└── states/ # Sample state files
# All unit tests (mock-based, fast)
pytest -m unit
# Specific test file
pytest tests/iac/unit/config/test_validation_edge_cases.py
# With verbose output
pytest -m unit -vRun time: ~10-30 seconds
# Set environment variable to enable real Dataiku testing
export USE_REAL_DATAIKU=true
# Run integration tests
pytest -m integration
# Run specific integration test
pytest tests/iac/integration/test_real_dataiku_sync.py -vRun time: ~1-5 minutes (depending on Dataiku instance)
# End-to-end workflow tests
pytest tests/iac/scenarios/
# Specific scenario
pytest tests/iac/scenarios/test_plan_workflow.py::TestSimpleProjectWorkflow# All tests (unit + integration + scenarios)
pytest
# Skip slow tests
pytest -m "not slow"
# Only smoke tests (quick validation)
pytest -m smokeTests are tagged with markers for selective execution:
| Marker | Purpose | Run Time |
|---|---|---|
unit |
Fast unit tests with mocks | Seconds |
integration |
Real Dataiku instance tests | Minutes |
slow |
Performance/scale tests | Minutes |
smoke |
Quick smoke tests for CI/CD | Seconds |
edge_case |
Edge case and error handling | Seconds |
cleanup_required |
Creates resources needing manual cleanup | Varies |
Usage:
# Run only unit tests
pytest -m unit
# Run integration tests
pytest -m integration
# Run everything except slow tests
pytest -m "not slow"
# Run smoke tests only
pytest -m smoke
# Combine markers
pytest -m "unit and edge_case"No configuration needed - tests use mocks.
Set these environment variables:
# Required
export USE_REAL_DATAIKU=true
# Optional - defaults provided
export DATAIKU_HOST="http://172.18.58.26:10000" # Default: local instance
export TEST_PROJECT_PREFIX="IAC_TEST_" # Default: IAC_TEST_
export TEST_PROJECT_KEY="IAC_TEST_PROJECT" # Optional: specific project to testNote: Running on the local box, API key is NOT required.
# All validation tests
pytest tests/iac/unit/config/
# Specific edge case tests
pytest tests/iac/unit/config/test_validation_edge_cases.py::TestNamingConventionEdgeCases# Existing state tests
pytest tests/iac/test_state.py
# State sync integration tests
pytest tests/iac/integration/test_real_dataiku_sync.py::TestStateManagerRealSync# Existing planner tests
pytest tests/iac/test_planner.py
# Scenario workflow tests
pytest tests/iac/scenarios/test_plan_workflow.py# All sync tests
export USE_REAL_DATAIKU=true
pytest tests/iac/integration/
# Just project sync
pytest tests/iac/integration/test_real_dataiku_sync.py::TestRealProjectSync
# Just dataset sync
pytest tests/iac/integration/test_real_dataiku_sync.py::TestRealDatasetSyncLocated in fixtures/configs/:
| Fixture | Purpose | Resources |
|---|---|---|
simple/project.yml |
Minimal config for smoke tests | 1 project, 1 dataset |
realistic/customer_analytics.yml |
Real-world analytics pipeline | 1 project, 7 datasets, 4 recipes |
complex/ml_pipeline.yml |
Complex ML workflow | 1 project, 15+ datasets, 10+ recipes |
edge_cases/invalid_naming.yml |
Invalid naming conventions | Invalid config |
edge_cases/circular_dependency.yml |
Circular dependencies | Invalid config |
Located in fixtures/states/:
| Fixture | Purpose |
|---|---|
empty_state.json |
Empty state for baseline tests |
simple_state.json |
State with one project and dataset |
# Test config parsing
pytest tests/iac/test_config_parser.py -v
# Test validation edge cases
pytest tests/iac/unit/config/test_validation_edge_cases.py -vexport USE_REAL_DATAIKU=true
export TEST_PROJECT_KEY="YOUR_PROJECT_KEY"
# Sync and validate
pytest tests/iac/integration/test_real_dataiku_sync.py::TestStateManagerRealSync::test_sync_project_with_children -v -s# Test plan generation workflow
pytest tests/iac/scenarios/test_plan_workflow.py::TestSimpleProjectWorkflow -v# Complete workflow with simple config
pytest tests/iac/scenarios/test_plan_workflow.py::TestSimpleProjectWorkflow::test_empty_to_full_plan -v -s
# Complete workflow with realistic config
pytest tests/iac/scenarios/test_plan_workflow.py::TestRealisticPipelineWorkflow -v -s# Run in CI - fast feedback
pytest -m unit --tb=shortRun time: ~30 seconds
# Requires Dataiku instance access
export USE_REAL_DATAIKU=true
export DATAIKU_HOST="http://172.18.58.26:10000"
pytest -m "unit or integration" --tb=shortRun time: ~5 minutes
# Run all tests including slow ones
pytest --tb=shortRun time: ~10-15 minutes
# More detailed output
pytest -v
# Show print statements
pytest -s
# Both
pytest -v -s# Run single test with full output
pytest tests/iac/unit/config/test_validation_edge_cases.py::TestNamingConventionEdgeCases::test_project_key_with_lowercase_fails -v -s# Drop into debugger on failure
pytest --pdb
# Drop into debugger on first failure
pytest -x --pdb# Show fixture setup/teardown
pytest --setup-show# Run tests with coverage
pytest --cov=dataikuapi.iac --cov-report=html --cov-report=term-missing
# Open HTML report
open htmlcov/index.html # macOS
xdg-open htmlcov/index.html # Linux# Coverage for specific module
pytest tests/iac/test_config_parser.py --cov=dataikuapi.iac.config.parser --cov-report=term-missingimport pytest
from dataikuapi.iac.config.validator import ConfigValidator
@pytest.mark.unit
class TestMyFeature:
"""Test my new feature"""
def test_basic_functionality(self):
"""Test basic use case"""
validator = ConfigValidator()
# Test logic here
assert True
def test_edge_case(self):
"""Test edge case"""
# Edge case logic
assert Trueimport pytest
@pytest.mark.integration
@pytest.mark.slow
class TestMyIntegration:
"""Test with real Dataiku"""
def test_with_real_instance(self, real_client, skip_if_no_real_dataiku):
"""Test against real Dataiku"""
try:
# Test logic using real_client
assert True
except Exception as e:
pytest.skip(f"Test failed: {e}")Cause: USE_REAL_DATAIKU not set
Solution:
export USE_REAL_DATAIKU=true
pytest -m integrationCause: Dataiku instance not accessible or wrong host
Solution:
# Verify host is correct
export DATAIKU_HOST="http://172.18.58.26:10000"
# Test connection
pytest tests/iac/integration/test_real_dataiku_sync.py::TestConnectionAndAuth::test_client_can_connect -v -sCause: Test project doesn't exist in Dataiku
Solution:
# Use existing project
export TEST_PROJECT_KEY="YOUR_EXISTING_PROJECT"
# Or tests will skip if project not foundCause: PYTHONPATH not set correctly
Solution:
# Run from repository root
cd /opt/dataiku/dss_install/dataiku-api-client-python
pytestExpected test execution times:
| Test Suite | Count | Time |
|---|---|---|
| Unit tests (mock-based) | ~200 | ~30s |
| Integration tests (real Dataiku) | ~20 | ~2m |
| Scenario tests | ~15 | ~1m |
| Total | ~235 | ~3m |
Note: Times vary based on system and Dataiku instance performance.
-
Performance Tests
- Large config files (100+ resources)
- State file size performance
- Sync performance benchmarks
-
CLI Tests
- All CLI flags and combinations
- Error messages and exit codes
- Output validation
-
State Corruption Tests
- Recovery from corrupted state files
- Version migration
- Backup/restore
-
Apply Execution Tests (Week 3)
- Resource creation
- Resource updates
- Resource deletion
- Rollback on failure
- Documentation:
../../docs/IAC_OVERVIEW.md - Planning Docs:
../../dataiku-iac-planning/ - Demo Scripts:
../../demos/week2_plan_workflow.py - IaC Source:
../../dataikuapi/iac/
When adding new tests:
- Follow existing patterns (see templates above)
- Use appropriate markers (
@pytest.mark.unit,@pytest.mark.integration, etc.) - Add docstrings explaining test purpose
- Use fixtures from
conftest.py - Update this README if adding new test categories
Last Updated: 2025-11-26 Test Suite Version: 2.0 IaC Version: Week 2 (Plan Generation)