@@ -610,51 +610,84 @@ def server.config
610
610
assert_equal ( '{"ok":true}' , response )
611
611
end
612
612
613
- def test_serverengine_config
614
- params = { }
615
- params [ 'workers' ] = 1
616
- params [ 'fluentd_conf_path' ] = "fluentd.conf"
617
- params [ 'use_v1_config' ] = true
618
- params [ 'conf_encoding' ] = 'utf-8'
619
- params [ 'log_level' ] = Fluent ::Log ::LEVEL_INFO
620
- load_config_proc = Proc . new { Fluent ::Supervisor . serverengine_config ( params ) }
621
-
622
- se_config = load_config_proc . call
623
- assert_equal Fluent ::Log ::LEVEL_INFO , se_config [ :log_level ]
624
- assert_equal 'spawn' , se_config [ :worker_type ]
625
- assert_equal 1 , se_config [ :workers ]
626
- assert_equal false , se_config [ :log_stdin ]
627
- assert_equal false , se_config [ :log_stdout ]
628
- assert_equal false , se_config [ :log_stderr ]
629
- assert_equal true , se_config [ :enable_heartbeat ]
630
- assert_equal false , se_config [ :auto_heartbeat ]
631
- assert_equal "fluentd.conf" , se_config [ :config_path ]
632
- assert_equal false , se_config [ :daemonize ]
633
- assert_nil se_config [ :pid_path ]
613
+ sub_test_case "serverengine_config" do
614
+ def test_normal
615
+ params = { }
616
+ params [ 'workers' ] = 1
617
+ params [ 'fluentd_conf_path' ] = "fluentd.conf"
618
+ params [ 'use_v1_config' ] = true
619
+ params [ 'conf_encoding' ] = 'utf-8'
620
+ params [ 'log_level' ] = Fluent ::Log ::LEVEL_INFO
621
+ load_config_proc = Proc . new { Fluent ::Supervisor . serverengine_config ( params ) }
622
+
623
+ se_config = load_config_proc . call
624
+ assert_equal Fluent ::Log ::LEVEL_INFO , se_config [ :log_level ]
625
+ assert_equal 'spawn' , se_config [ :worker_type ]
626
+ assert_equal 1 , se_config [ :workers ]
627
+ assert_equal false , se_config [ :log_stdin ]
628
+ assert_equal false , se_config [ :log_stdout ]
629
+ assert_equal false , se_config [ :log_stderr ]
630
+ assert_equal true , se_config [ :enable_heartbeat ]
631
+ assert_equal false , se_config [ :auto_heartbeat ]
632
+ assert_equal "fluentd.conf" , se_config [ :config_path ]
633
+ assert_equal false , se_config [ :daemonize ]
634
+ assert_nil se_config [ :pid_path ]
635
+ end
636
+
637
+ def test_daemonize
638
+ params = { }
639
+ params [ 'workers' ] = 1
640
+ params [ 'fluentd_conf_path' ] = "fluentd.conf"
641
+ params [ 'use_v1_config' ] = true
642
+ params [ 'conf_encoding' ] = 'utf-8'
643
+ params [ 'log_level' ] = Fluent ::Log ::LEVEL_INFO
644
+ params [ 'daemonize' ] = './fluentd.pid'
645
+ load_config_proc = Proc . new { Fluent ::Supervisor . serverengine_config ( params ) }
646
+
647
+ se_config = load_config_proc . call
648
+ assert_equal Fluent ::Log ::LEVEL_INFO , se_config [ :log_level ]
649
+ assert_equal 'spawn' , se_config [ :worker_type ]
650
+ assert_equal 1 , se_config [ :workers ]
651
+ assert_equal false , se_config [ :log_stdin ]
652
+ assert_equal false , se_config [ :log_stdout ]
653
+ assert_equal false , se_config [ :log_stderr ]
654
+ assert_equal true , se_config [ :enable_heartbeat ]
655
+ assert_equal false , se_config [ :auto_heartbeat ]
656
+ assert_equal "fluentd.conf" , se_config [ :config_path ]
657
+ assert_equal true , se_config [ :daemonize ]
658
+ assert_equal './fluentd.pid' , se_config [ :pid_path ]
659
+ end
660
+
661
+ data ( "nil" , [ nil , nil ] )
662
+ data ( "default" , [ "0" , 0 ] )
663
+ data ( "000" , [ "000" , 0 ] )
664
+ data ( "0000" , [ "0000" , 0 ] )
665
+ data ( "2" , [ "2" , 2 ] )
666
+ data ( "222" , [ "222" , 146 ] )
667
+ data ( "0222" , [ "0222" , 146 ] )
668
+ data ( "0 as integer" , [ 0 , 0 ] )
669
+ def test_chumask ( ( chumask , expected ) )
670
+ params = { "chumask" => chumask }
671
+ load_config_proc = Proc . new { Fluent ::Supervisor . serverengine_config ( params ) }
672
+
673
+ se_config = load_config_proc . call
674
+
675
+ assert_equal expected , se_config [ :chumask ]
676
+ end
634
677
end
635
678
636
- def test_serverengine_config_for_daemonize
637
- params = { }
638
- params [ 'workers' ] = 1
639
- params [ 'fluentd_conf_path' ] = "fluentd.conf"
640
- params [ 'use_v1_config' ] = true
641
- params [ 'conf_encoding' ] = 'utf-8'
642
- params [ 'log_level' ] = Fluent ::Log ::LEVEL_INFO
643
- params [ 'daemonize' ] = './fluentd.pid'
644
- load_config_proc = Proc . new { Fluent ::Supervisor . serverengine_config ( params ) }
645
-
646
- se_config = load_config_proc . call
647
- assert_equal Fluent ::Log ::LEVEL_INFO , se_config [ :log_level ]
648
- assert_equal 'spawn' , se_config [ :worker_type ]
649
- assert_equal 1 , se_config [ :workers ]
650
- assert_equal false , se_config [ :log_stdin ]
651
- assert_equal false , se_config [ :log_stdout ]
652
- assert_equal false , se_config [ :log_stderr ]
653
- assert_equal true , se_config [ :enable_heartbeat ]
654
- assert_equal false , se_config [ :auto_heartbeat ]
655
- assert_equal "fluentd.conf" , se_config [ :config_path ]
656
- assert_equal true , se_config [ :daemonize ]
657
- assert_equal './fluentd.pid' , se_config [ :pid_path ]
679
+ data ( "default" , [ { } , "0" ] )
680
+ data ( "222" , [ { chumask : "222" } , "222" ] )
681
+ def test_chumask_should_be_passed_to_ServerEngine ( ( cl_opt , expected_chumask_value ) )
682
+ proxy . mock ( Fluent ::Supervisor ) . serverengine_config ( hash_including ( "chumask" => expected_chumask_value ) )
683
+ any_instance_of ( ServerEngine ::Daemon ) { |daemon | mock ( daemon ) . run . once }
684
+
685
+ supervisor = Fluent ::Supervisor . new ( cl_opt )
686
+ stub ( Fluent ::Config ) . build { config_element ( 'ROOT' ) }
687
+ stub ( supervisor ) . build_spawn_command { "dummy command line" }
688
+ supervisor . configure ( supervisor : true )
689
+
690
+ supervisor . run_supervisor
658
691
end
659
692
660
693
sub_test_case "init logger" do
0 commit comments