<commit_before># Create Admin Account
Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Administrator',
  password: 'password',
  password_confirmation: 'password',
  admin: true
)

# Create Guest Account
Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Guest User',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)

# Create Project X
project_x = Project.find_or_create_by!(
  name: 'Project X',
  description: 'Project X description'
)

# Create Account and Assign Project X as Administrator
x_admin = Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Project X Administrator',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)
project_x.assign_project_member(x_admin, :administrator)

# Create Account and Assign Project X as Operator
x_operator = Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Project X Operator',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)
project_x.assign_project_member(x_operator)

# Create Project X Resources

# Cloud
cloud = Cloud.find_or_create_by!(
  name: 'AWS Tokyo Region',
  type: 'aws',
  entry_point: 'ap-northeast-1',
  key: 'dummy_access_key',
  secret: 'dummy_secret_key',
  project_id: project_x.id
)

# Blueprint and Pattern
Pattern.skip_callback(:save, :before, :execute_packer)
Blueprint.skip_callback(:create, :before, :update_consul_secret_key)
blueprint = Blueprint.where(name: 'tomcat').first_or_create!(
  project_id: project_x.id,
  name: 'tomcat',
  description: 'Apache, Tomcat, PostgreSQL',
  consul_secret_key: '<KEY>',
  patterns_attributes: [{
    url: 'https://github.com/cloudconductor-patterns/tomcat_pattern.git',
    revision: 'master'
  }]
)
blueprint.patterns.first.update(
  name: 'tomcat_pattern',
  type: 'platform'
)
Pattern.set_callback(:save, :before, :execute_packer)
Blueprint.set_callback(:create, :before, :update_consul_secret_key)

# System
System.skip_callback(:save, :before, :update_dns)
System.skip_callback(:save, :before, :enable_monitoring)
system = System.find_or_create_by!(
  project_id: project_x.id,
  name: 'sample_system_1',
  description: 'sample_system_1',
  domain: 'sample.example.com'<commit_msg>Fix testdata<commit_after># Create Admin Account
Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Administrator',
  password: 'password',
  password_confirmation: 'password',
  admin: true
)

# Create Guest Account
Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Guest User',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)

# Create Project X
project_x = Project.find_or_create_by!(
  name: 'Project X',
  description: 'Project X description'
)

# Create Account and Assign Project X as Administrator
x_admin = Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: 'Project X Administrator',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)
project_x.assign_project_member(x_admin, :administrator)

# Create Account and Assign Project X as Operator
x_operator = Account.where(email: '<EMAIL>').first_or_create!(
  email: '<EMAIL>',
  name: '<NAME>',
  password: 'password',
  password_confirmation: 'password',
  admin: false
)
project_x.assign_project_member(x_operator)

# Create Project X Resources

# Cloud
cloud = Cloud.find_or_create_by!(
  name: 'AWS Tokyo Region',
  type: 'aws',
  entry_point: 'ap-northeast-1',
  key: 'dummy_access_key',
  secret: 'dummy_secret_key',
  project_id: project_x.id
)

# Blueprint and Pattern
Pattern.skip_callback(:save, :before, :execute_packer)
Blueprint.skip_callback(:create, :before, :update_consul_secret_key)
blueprint = Blueprint.where(name: 'tomcat').first_or_create!(
  project_id: project_x.id,
  name: 'tomcat',
  description: 'Apache, Tomcat, PostgreSQL',
  consul_secret_key: '<KEY>',
  patterns_attributes: [{
    url: 'https://github.com/cloudconductor-patterns/tomcat_pattern.git',
    revision: 'master'
  }]
)
blueprint.patterns.first.update(
  name: 'tomcat_pattern',
  type: 'platform'
)
blueprint.patterns.first.images.where(image: 'ami-12345678').first_or_create!(
  cloud: cloud,
  base_image: cloud.base_images.first,
  name: 'test',
  role: 'web',
  image: 'ami-12345678',
  status: 'CREATE_COMPLETE'
)
Pattern.set_callback(:save, :before, :execute_packer)
Blueprint.set_callback(:create, :before, :update_consul_secret_key)

# System
System.skip_callback(:save, :before, :update_dns)
System.skip_callback(:save, :before, :enable_monitoring)
system = System.find_or_create_by!(
  project_id: project_x.id,
  name: 'sample_system_1',
  description: 'sample_system_1',
  domain: 'sample.example.com'
{'fraction_non_alphanumeric': 0.13973799126637554, 'fraction_numerical': 0.004574755666458723, 'mean_word_length': 5.991279069767442, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3340037', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1653, 'n_words': 350}