Ansible role to manage Nodepool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_role.py 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Copyright 2018 Red Hat, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. import pytest
  15. def test_nodepool_user(host):
  16. user = host.user('nodepool')
  17. assert user.exists
  18. assert user.name == 'nodepool'
  19. assert user.group == 'nodepool'
  20. assert user.home == '/var/lib/nodepool'
  21. f = host.file('/var/lib/nodepool')
  22. assert f.exists
  23. assert f.is_directory
  24. assert f.user == 'nodepool'
  25. assert f.group == 'nodepool'
  26. assert f.mode == 0o755
  27. def test_nodepool_config(host):
  28. f = host.file('/etc/nodepool')
  29. assert f.exists
  30. assert f.is_directory
  31. assert f.user == 'nodepool'
  32. assert f.group == 'nodepool'
  33. # TODO(pabelanger): Validate mode
  34. del f
  35. f = host.file('/etc/nodepool/nodepool.yaml')
  36. assert f.exists
  37. assert f.is_file
  38. assert f.user == 'nodepool'
  39. assert f.group == 'nodepool'
  40. assert f.mode == 0o644
  41. del f
  42. f = host.file('/etc/nodepool/secure.conf')
  43. assert f.exists
  44. assert f.is_file
  45. assert f.user == 'nodepool'
  46. assert f.group == 'nodepool'
  47. assert f.mode == 0o600
  48. def test_nodepool_images_directory(host):
  49. f = host.file('/opt/nodepool/images')
  50. assert f.exists
  51. assert f.is_directory
  52. assert f.user == 'nodepool'
  53. assert f.group == 'nodepool'
  54. assert f.mode == 0o755
  55. def test_nodepool_logs_directory(host):
  56. f = host.file('/var/log/nodepool')
  57. assert f.exists
  58. assert f.is_directory
  59. assert f.user == 'nodepool'
  60. assert f.group == 'nodepool'
  61. assert f.mode == 0o755
  62. def test_nodepool_builder_logging_config(host):
  63. f = host.file('/etc/nodepool/builder-logging.conf')
  64. assert f.exists
  65. assert f.is_file
  66. assert f.user == 'nodepool'
  67. assert f.group == 'nodepool'
  68. assert f.mode == 0o644
  69. def test_nodepool_builder_service_config(host):
  70. f = host.file('/etc/systemd/system/nodepool-builder.service')
  71. assert f.exists
  72. assert f.is_file
  73. assert f.user == 'root'
  74. assert f.group == 'root'
  75. assert f.mode == 0o644
  76. del f
  77. f = host.file('/etc/systemd/system/nodepool-builder.service.d')
  78. assert f.exists
  79. assert f.is_directory
  80. assert f.user == 'root'
  81. assert f.group == 'root'
  82. assert f.mode == 0o755
  83. del f
  84. f = host.file(
  85. '/etc/systemd/system/nodepool-builder.service.d/override.conf')
  86. assert f.exists
  87. assert f.is_file
  88. assert f.user == 'root'
  89. assert f.group == 'root'
  90. assert f.mode == 0o644
  91. @pytest.mark.skip_if_docker()
  92. def test_nodepool_builder_service(host):
  93. service = host.service('nodepool-builder')
  94. assert service.is_running
  95. assert service.is_enabled
  96. def test_nodepool_launcher_logging_config(host):
  97. f = host.file('/etc/nodepool/launcher-logging.conf')
  98. assert f.exists
  99. assert f.is_file
  100. assert f.user == 'nodepool'
  101. assert f.group == 'nodepool'
  102. assert f.mode == 0o644
  103. def test_nodepool_launcher_service_config(host):
  104. f = host.file('/etc/systemd/system/nodepool-launcher.service')
  105. assert f.exists
  106. assert f.is_file
  107. assert f.user == 'root'
  108. assert f.group == 'root'
  109. assert f.mode == 0o644
  110. del f
  111. f = host.file('/etc/systemd/system/nodepool-launcher.service.d')
  112. assert f.exists
  113. assert f.is_directory
  114. assert f.user == 'root'
  115. assert f.group == 'root'
  116. assert f.mode == 0o755
  117. del f
  118. f = host.file(
  119. '/etc/systemd/system/nodepool-launcher.service.d/override.conf')
  120. assert f.exists
  121. assert f.is_file
  122. assert f.user == 'root'
  123. assert f.group == 'root'
  124. assert f.mode == 0o644
  125. @pytest.mark.skip_if_docker()
  126. def test_nodepool_launcher_service(host):
  127. service = host.service('nodepool-launcher')
  128. assert service.is_running
  129. assert service.is_enabled