|
463 | 463 | end |
464 | 464 | end |
465 | 465 | end |
| 466 | + |
| 467 | + describe 'when overriding global and defaults options with user-supplied overrides and additions' do |
| 468 | + # For testing the merging functionality we restrict ourselves to |
| 469 | + # Debian OS family so that we don't have to juggle different sets of |
| 470 | + # global_options and defaults_options (like for FreeBSD). |
| 471 | + ['Debian' ].each do |osfamily| |
| 472 | + context "on #{osfamily} family operatingsystems" do |
| 473 | + let(:facts) do |
| 474 | + { :osfamily => osfamily }.merge default_facts |
| 475 | + end |
| 476 | + let(:contents) { param_value(catalogue, 'concat::fragment', 'haproxy-haproxy-base', 'content').split("\n") } |
| 477 | + let(:params) do |
| 478 | + { |
| 479 | + 'merge_options' => false, |
| 480 | + 'global_options' => { |
| 481 | + 'log-send-hostname' => '', |
| 482 | + 'chroot' => '/srv/haproxy-chroot', |
| 483 | + 'stats' => [ |
| 484 | + 'socket /var/lib/haproxy/admin.sock mode 660 level admin', |
| 485 | + 'timeout 30s' |
| 486 | + ] |
| 487 | + }, |
| 488 | + 'defaults_options' => { |
| 489 | + 'mode' => 'http', |
| 490 | + 'option' => [ |
| 491 | + 'abortonclose', |
| 492 | + 'logasap', |
| 493 | + 'dontlognull', |
| 494 | + 'httplog', |
| 495 | + 'http-server-close', |
| 496 | + 'forwardfor except 127.0.0.1', |
| 497 | + ], |
| 498 | + 'timeout' => [ |
| 499 | + 'connect 5s', |
| 500 | + 'client 1m', |
| 501 | + 'server 1m', |
| 502 | + 'check 7s', |
| 503 | + ] |
| 504 | + }, |
| 505 | + } |
| 506 | + end |
| 507 | + it 'should manage a custom chroot directory' do |
| 508 | + subject.should contain_file('/srv/haproxy-chroot').with( |
| 509 | + 'ensure' => 'directory' |
| 510 | + ) |
| 511 | + end |
| 512 | + it 'should contain global and defaults sections' do |
| 513 | + contents.should include('global') |
| 514 | + contents.should include('defaults') |
| 515 | + end |
| 516 | + it 'should send hostname with log in global options' do |
| 517 | + contents.should include(' log-send-hostname ') |
| 518 | + end |
| 519 | + it 'should enable admin stats and stats timeout in global options' do |
| 520 | + contents.should include(' stats socket /var/lib/haproxy/admin.sock mode 660 level admin') |
| 521 | + contents.should include(' stats timeout 30s') |
| 522 | + end |
| 523 | + it 'should set mode http in default options' do |
| 524 | + contents.should include(' mode http') |
| 525 | + end |
| 526 | + it 'should not set the global parameter "maxconn"' do |
| 527 | + contents.should_not include(' maxconn 4000') |
| 528 | + end |
| 529 | + it 'should set various options in defaults, removing the "redispatch" option' do |
| 530 | + contents.should_not include(' option redispatch') |
| 531 | + contents.should include(' option abortonclose') |
| 532 | + contents.should include(' option logasap') |
| 533 | + contents.should include(' option dontlognull') |
| 534 | + contents.should include(' option httplog') |
| 535 | + contents.should include(' option http-server-close') |
| 536 | + contents.should include(' option forwardfor except 127.0.0.1') |
| 537 | + end |
| 538 | + it 'should set timeouts in defaults, removing the "http-request 10s" and "queue 1m" timeout' do |
| 539 | + contents.should_not include(' timeout http-request 10s') |
| 540 | + contents.should_not include(' timeout queue 1m') |
| 541 | + contents.should include(' timeout connect 5s') |
| 542 | + contents.should include(' timeout check 7s') |
| 543 | + contents.should include(' timeout client 1m') |
| 544 | + contents.should include(' timeout server 1m') |
| 545 | + end |
| 546 | + end |
| 547 | + end |
| 548 | + end |
| 549 | + |
| 550 | + describe 'when specifying global_options with arrays instead of hashes' do |
| 551 | + # For testing input validation we restrict ourselves to |
| 552 | + # Debian OS family so that we don't have to juggle different sets of |
| 553 | + # global_options and defaults_options (like for FreeBSD). |
| 554 | + ['Debian' ].each do |osfamily| |
| 555 | + context "on #{osfamily} family operatingsystems" do |
| 556 | + let(:facts) do |
| 557 | + { :osfamily => osfamily }.merge default_facts |
| 558 | + end |
| 559 | + let(:contents) { param_value(catalogue, 'concat::fragment', 'haproxy-haproxy-base', 'content').split("\n") } |
| 560 | + let(:params) do |
| 561 | + { |
| 562 | + 'merge_options' => true, |
| 563 | + 'global_options' => [ 'log-send-hostname', 'chroot /srv/haproxy-chroot' ] |
| 564 | + } |
| 565 | + end |
| 566 | + it 'should raise error' do |
| 567 | + expect { catalogue }.to raise_error Puppet::Error, /is not a Hash/ |
| 568 | + end |
| 569 | + end |
| 570 | + end |
| 571 | + end |
| 572 | + describe 'when specifying defaults_options with arrays instead of hashes' do |
| 573 | + # For testing input validation we restrict ourselves to |
| 574 | + # Debian OS family so that we don't have to juggle different sets of |
| 575 | + # global_options and defaults_options (like for FreeBSD). |
| 576 | + ['Debian' ].each do |osfamily| |
| 577 | + context "on #{osfamily} family operatingsystems" do |
| 578 | + let(:facts) do |
| 579 | + { :osfamily => osfamily }.merge default_facts |
| 580 | + end |
| 581 | + let(:contents) { param_value(catalogue, 'concat::fragment', 'haproxy-haproxy-base', 'content').split("\n") } |
| 582 | + let(:params) do |
| 583 | + { |
| 584 | + 'merge_options' => true, |
| 585 | + 'defaults_options' => [ |
| 586 | + 'mode http', |
| 587 | + 'timeout connect 5s', |
| 588 | + 'timeout client 1m' |
| 589 | + ] |
| 590 | + } |
| 591 | + end |
| 592 | + it 'should raise error' do |
| 593 | + expect { catalogue }.to raise_error Puppet::Error, /is not a Hash/ |
| 594 | + end |
| 595 | + end |
| 596 | + end |
| 597 | + end |
466 | 598 | end |
467 | 599 |
|
468 | 600 | context 'on unsupported operatingsystems' do |
|
0 commit comments