xref: /unit/test/unit/applications/lang/ruby.py (revision 1971:3410f9d2a662)
11911So.canty@f5.comimport shutil
21911So.canty@f5.com
31019Szelenkov@nginx.comfrom unit.applications.proto import TestApplicationProto
41730Szelenkov@nginx.comfrom unit.option import option
51911So.canty@f5.comfrom unit.utils import public_dir
61019Szelenkov@nginx.com
71019Szelenkov@nginx.com
81019Szelenkov@nginx.comclass TestApplicationRuby(TestApplicationProto):
91116Szelenkov@nginx.com    application_type = "ruby"
101116Szelenkov@nginx.com
111911So.canty@f5.com    def prepare_env(self, script):
121911So.canty@f5.com        shutil.copytree(
131911So.canty@f5.com            option.test_dir + '/ruby/' + script,
14*1912So.canty@f5.com            option.temp_dir + '/ruby/' + script,
151911So.canty@f5.com        )
161911So.canty@f5.com
171911So.canty@f5.com        public_dir(option.temp_dir + '/ruby/' + script)
181911So.canty@f5.com
191303St.nateldemoura@f5.com    def load(self, script, name='config.ru', **kwargs):
201911So.canty@f5.com        self.prepare_env(script)
211911So.canty@f5.com
221911So.canty@f5.com        script_path = option.temp_dir + '/ruby/' + script
231019Szelenkov@nginx.com
24*1912So.canty@f5.com        app = {
25*1912So.canty@f5.com            "type": self.get_application_type(),
26*1912So.canty@f5.com            "processes": {"spare": 0},
27*1912So.canty@f5.com            "working_directory": script_path,
28*1912So.canty@f5.com            "script": script_path + '/' + name,
29*1912So.canty@f5.com        }
30*1912So.canty@f5.com
31*1912So.canty@f5.com        for key in [
32*1912So.canty@f5.com            'hooks',
33*1912So.canty@f5.com        ]:
34*1912So.canty@f5.com            if key in kwargs:
35*1912So.canty@f5.com                app[key] = kwargs[key]
36*1912So.canty@f5.com
371050Szelenkov@nginx.com        self._load_conf(
381019Szelenkov@nginx.com            {
391041Svbart@nginx.com                "listeners": {"*:7080": {"pass": "applications/" + script}},
40*1912So.canty@f5.com                "applications": {script: app},
411303St.nateldemoura@f5.com            },
421303St.nateldemoura@f5.com            **kwargs
431019Szelenkov@nginx.com        )
44