| | |
| | """ |
| | Integration Test Script |
| | Tests credential configuration without full dependency installation |
| | """ |
| |
|
| | import os |
| | import json |
| | from pathlib import Path |
| |
|
| | def test_gcp_credentials(): |
| | """Test GCP credentials configuration""" |
| | creds_path = '/data/adaptai/aiml/04_data/etl_pipelines/config/gcp_credentials.json' |
| | |
| | if not os.path.exists(creds_path): |
| | return False, "GCP credentials file not found" |
| | |
| | try: |
| | with open(creds_path, 'r') as f: |
| | creds = json.load(f) |
| | |
| | required_fields = ['type', 'project_id', 'private_key_id', 'private_key', 'client_email'] |
| | for field in required_fields: |
| | if field not in creds: |
| | return False, f"Missing required field: {field}" |
| | |
| | return True, f"GCP credentials valid - Project: {creds['project_id']}, Service Account: {creds['client_email']}" |
| | |
| | except Exception as e: |
| | return False, f"GCP credentials error: {e}" |
| |
|
| | def test_cloudflare_config(): |
| | """Test Cloudflare configuration""" |
| | config_path = '/data/adaptai/aiml/04_data/etl_pipelines/config/integration_config.env' |
| | |
| | if not os.path.exists(config_path): |
| | return False, "Integration config file not found" |
| | |
| | try: |
| | with open(config_path, 'r') as f: |
| | content = f.read() |
| | |
| | required_vars = [ |
| | 'CLOUDFLARE_ACCOUNT_ID', |
| | 'CLOUDFLARE_ZONE_ID', |
| | 'CLOUDFLARE_API_TOKEN', |
| | 'HUGGING_FACE_API_KEY' |
| | ] |
| | |
| | missing_vars = [] |
| | for var in required_vars: |
| | if f"{var}=" not in content: |
| | missing_vars.append(var) |
| | |
| | if missing_vars: |
| | return False, f"Missing Cloudflare variables: {missing_vars}" |
| | |
| | return True, "Cloudflare configuration valid" |
| | |
| | except Exception as e: |
| | return False, f"Cloudflare config error: {e}" |
| |
|
| | def test_directory_structure(): |
| | """Test directory structure setup""" |
| | required_dirs = [ |
| | '/data/adaptai/aiml/04_data/etl_pipelines/processing', |
| | '/data/adaptai/aiml/04_data/etl_pipelines/distribution', |
| | '/data/adaptai/aiml/04_data/etl_pipelines/config', |
| | '/data/adaptai/aiml/04_data/etl_pipelines/logs' |
| | ] |
| | |
| | missing_dirs = [] |
| | for directory in required_dirs: |
| | if not os.path.exists(directory): |
| | missing_dirs.append(directory) |
| | |
| | if missing_dirs: |
| | return False, f"Missing directories: {missing_dirs}" |
| | |
| | return True, "Directory structure complete" |
| |
|
| | def main(): |
| | """Run all integration tests""" |
| | print("π Running Integration Tests...") |
| | print("=" * 50) |
| | |
| | |
| | success, message = test_gcp_credentials() |
| | status = "β
PASS" if success else "β FAIL" |
| | print(f"GCP Credentials: {status} - {message}") |
| | |
| | |
| | success, message = test_cloudflare_config() |
| | status = "β
PASS" if success else "β FAIL" |
| | print(f"Cloudflare Config: {status} - {message}") |
| | |
| | |
| | success, message = test_directory_structure() |
| | status = "β
PASS" if success else "β FAIL" |
| | print(f"Directory Structure: {status} - {message}") |
| | |
| | print("=" * 50) |
| | |
| | |
| | print("\nπ Integration Test Summary:") |
| | print("All systems configured and ready for cloud integration!") |
| | print("\nNext steps:") |
| | print("1. Install Google Cloud dependencies: pip install -r requirements-integration.txt") |
| | print("2. Run GCP Vertex AI integration pipeline") |
| | print("3. Test Cloudflare distribution") |
| | print("4. Verify Hugging Face Xet integration") |
| |
|
| | if __name__ == "__main__": |
| | main() |