/tests/beaker_tests/cisco_object_group/test_object_group.rb

https://github.com/cisco/cisco-network-puppet-module · Ruby · 110 lines · 65 code · 14 blank · 31 comment · 0 complexity · 53db58230d14688674cbd86b0f2cf75b MD5 · raw file

  1. ###############################################################################
  2. # Copyright (c) 2017 Cisco and/or its affiliates.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ###############################################################################
  16. #
  17. # See README-develop-beaker-scripts.md (Section: Test Script Variable Reference)
  18. # for information regarding:
  19. # - test script general prequisites
  20. # - command return codes
  21. # - A description of the 'tests' hash and its usage
  22. #
  23. ###############################################################################
  24. require File.expand_path('../../lib/utilitylib.rb', __FILE__)
  25. # Test hash top-level keys
  26. tests = {
  27. master: master,
  28. agent: agent,
  29. platform: 'n(3|7|9)k',
  30. resource_name: 'cisco_object_group_entry',
  31. }
  32. # Skip -ALL- tests if a top-level platform/os key exludes this platform
  33. skip_unless_supported(tests)
  34. tests[:seq_10_v4] = {
  35. title_pattern: 'ipv4 address beaker 10',
  36. manifest_props: {
  37. address: '1.2.3.4 2.3.4.5'
  38. },
  39. }
  40. tests[:seq_10_v6] = {
  41. desc: 'IPv6 Seq 10',
  42. title_pattern: 'ipv6 address beaker6 10',
  43. manifest_props: {
  44. address: '1:1::1/64'
  45. },
  46. }
  47. tests[:seq_20_v4] = {
  48. title_pattern: 'ipv4 port beakerp 20',
  49. manifest_props: {
  50. port: 'eq 40'
  51. },
  52. }
  53. tests[:seq_30_v4] = {
  54. desc: 'IPv4 Seq 30',
  55. title_pattern: 'ipv4 port beakerp 30',
  56. manifest_props: {
  57. port: 'range 300 550'
  58. },
  59. }
  60. # class to contain the test_dependencies specific to this test case
  61. class TestObjectGroup < BaseHarness
  62. def self.dependency_manifest(_ctx, _tests, _id)
  63. "
  64. cisco_object_group { 'ipv4 address beaker':
  65. ensure => present,
  66. }
  67. cisco_object_group { 'ipv6 address beaker6':
  68. ensure => present,
  69. }
  70. cisco_object_group { 'ipv4 port beakerp':
  71. ensure => present,
  72. }
  73. "
  74. end
  75. end
  76. def cleanup
  77. logger.info('Testcase Cleanup:')
  78. resource_absent_cleanup(agent, 'cisco_object_group_entry')
  79. resource_absent_cleanup(agent, 'cisco_object_group')
  80. end
  81. #################################################################
  82. # TEST CASE EXECUTION
  83. #################################################################
  84. test_name "TestCase :: #{tests[:resource_name]}" do
  85. cleanup
  86. teardown { cleanup }
  87. # ---------------------------------------------------------
  88. logger.info("\n#{'-' * 60}\nSection 1. ObjectGroup Testing")
  89. test_harness_run(tests, :seq_10_v4, harness_class: TestObjectGroup)
  90. test_harness_run(tests, :seq_10_v6, harness_class: TestObjectGroup)
  91. test_harness_run(tests, :seq_20_v4, harness_class: TestObjectGroup)
  92. test_harness_run(tests, :seq_30_v4, harness_class: TestObjectGroup)
  93. # ---------------------------------------------------------
  94. skipped_tests_summary(tests)
  95. end
  96. logger.info("TestCase :: #{tests[:resource_name]} :: End")