1
0

__init__.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- coding: utf-8 -*-
  2. """
  3. tests.unit.cloud
  4. ~~~~~~~~~~~~~~~~
  5. """
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import salt.cloud
  8. from tests.support.helpers import slowTest
  9. from tests.support.unit import TestCase
  10. class CloudTest(TestCase):
  11. @slowTest
  12. def test_vm_config_merger(self):
  13. """
  14. Validate the vm's config is generated correctly.
  15. https://github.com/saltstack/salt/issues/49226
  16. """
  17. main = {
  18. "minion": {"master": "172.31.39.213"},
  19. "log_file": "var/log/salt/cloud.log",
  20. "pool_size": 10,
  21. }
  22. provider = {
  23. "private_key": "dwoz.pem",
  24. "grains": {"foo1": "bar", "foo2": "bang"},
  25. "availability_zone": "us-west-2b",
  26. "driver": "ec2",
  27. "ssh_interface": "private_ips",
  28. "ssh_username": "admin",
  29. "location": "us-west-2",
  30. }
  31. profile = {
  32. "profile": "default",
  33. "grains": {"meh2": "bar", "meh1": "foo"},
  34. "provider": "ec2-default:ec2",
  35. "ssh_username": "admin",
  36. "image": "ami-0a1fbca0e5b419fd1",
  37. "size": "t2.micro",
  38. }
  39. vm = salt.cloud.Cloud.vm_config("test_vm", main, provider, profile, {})
  40. self.assertEqual(
  41. {
  42. "minion": {"master": "172.31.39.213"},
  43. "log_file": "var/log/salt/cloud.log",
  44. "pool_size": 10,
  45. "private_key": "dwoz.pem",
  46. "grains": {
  47. "foo1": "bar",
  48. "foo2": "bang",
  49. "meh2": "bar",
  50. "meh1": "foo",
  51. },
  52. "availability_zone": "us-west-2b",
  53. "driver": "ec2",
  54. "ssh_interface": "private_ips",
  55. "ssh_username": "admin",
  56. "location": "us-west-2",
  57. "profile": "default",
  58. "provider": "ec2-default:ec2",
  59. "image": "ami-0a1fbca0e5b419fd1",
  60. "size": "t2.micro",
  61. "name": "test_vm",
  62. },
  63. vm,
  64. )