Skip to content

Create CKAN development population script #99

Description

@mosoriob

Summary

Create a script that allows developers to quickly populate CKAN with test users, organizations, and datasets for development and testing purposes.

Description

Based on the existing test plan in docs/test-potree-permissions.md, we need automated scripts to set up a complete test environment with different user permission levels and sample data.

Requirements

Core Functionality

  • Create test users with different permission levels:
    • Sysadmin users
    • Regular users
    • Organization editors
  • Create test organizations with proper member assignments
  • Create sample datasets within organizations
  • Generate API tokens for all test users
  • Support both development and production environments

Script Structure

scripts/
├── dev-setup/
│   ├── populate-ckan.sh          # Main population script
│   ├── create-users.sh           # User creation utilities
│   ├── create-orgs.sh            # Organization setup
│   ├── create-datasets.sh        # Sample dataset creation
│   └── cleanup.sh                # Environment cleanup

User Types to Create

  1. Admin User (admin): Sysadmin with full permissions
  2. Org Editor (org-editor): Editor role in test organization
  3. Regular User (regular-user): Standard user with no special permissions
  4. Guest User (guest): Minimal permissions for testing

Organizations to Create

  • test-org: Primary test organization
  • research-group: Secondary organization for multi-org testing
  • public-data: Organization for public datasets

Sample Datasets

  • Potree point cloud datasets with scene.json5 files
  • Regular file uploads
  • Datasets with different visibility levels (public/private)
  • Datasets in different organizations

Implementation Details

Environment Detection

  • Auto-detect development vs production environment
  • Use appropriate Docker Compose files (docker-compose.dev.yml vs docker-compose.yml)
  • Handle different CKAN container names

Configuration Options

# Usage examples
./scripts/dev-setup/populate-ckan.sh --env dev
./scripts/dev-setup/populate-ckan.sh --env prod --users-only
./scripts/dev-setup/populate-ckan.sh --cleanup

API Token Management

  • Generate and display API tokens for all created users
  • Option to save tokens to file for automated testing
  • Support for both CKAN 2.9 API tokens and legacy API keys

Acceptance Criteria

  • Script creates users with correct permission levels
  • Organizations are created with proper member assignments
  • Sample datasets are created in appropriate organizations
  • API tokens are generated and accessible
  • Script works in both dev and production environments
  • Cleanup script removes all test data
  • Documentation includes usage examples
  • Script handles errors gracefully (existing users, etc.)

Files Referenced

  • docs/test-potree-permissions.md - Contains the manual commands to automate
  • CLAUDE.md - Docker commands and environment setup
  • .env.dev.config / .env.prod.config - Environment configuration

Benefits

  • Faster development environment setup
  • Consistent test data across developer machines
  • Automated testing capabilities
  • Easy permission testing for new features
  • Simplified onboarding for new developers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions