pax_global_header 0000666 0000000 0000000 00000000064 14134547230 0014515 g ustar 00root root 0000000 0000000 52 comment=ae722678a1b51b525863b7a2d8e6a936e8dc7f31 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/ 0000775 0000000 0000000 00000000000 14134547230 0023154 5 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/ 0000775 0000000 0000000 00000000000 14134547230 0025006 5 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/ 0000775 0000000 0000000 00000000000 14134547230 0026363 5 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/README.md 0000664 0000000 0000000 00000000746 14134547230 0027651 0 ustar 00root root 0000000 0000000 # Html5 Application Server # ## Presentation ## * Fast hosting software for static website (html5) * Use Nginx server ## Parameter ## download_url (string) :required Details : * Only tarball (tar) is supported * Compressed format is gunzip (optional) * Tarball must contain an index.html at its root ## How it works ## Each time you (re)start your instance or update parameters, html5as will remove previous website then download tarball and extract it in docroot directory. slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/buildout.hash.cfg 0000664 0000000 0000000 00000003212 14134547230 0031613 0 ustar 00root root 0000000 0000000 # To learn more about how to generate this file read # ../../README.update-hash.rst # THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax. # The only allowed lines here are (regexes): # - "^#" comments, copied verbatim # - "^[" section beginings, copied verbatim # - lines containing an "=" sign which must fit in the following categorie. # - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file # Copied verbatim. # - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported # by the re-generation script. # Re-generated. # - other lines are copied verbatim # Substitution (${...:...}), extension ([buildout] extends = ...) and # section inheritance (< = ...) are NOT supported (but you should really # not need these here). [template-cfg] filename = instance.cfg.in md5sum = 9e486efe4ab1aba8cb72b04f6c6da8ad [instance_html5as] _update_hash_filename_ = instance_html5as.cfg.in md5sum = f86b2f37c0acd21ca1f41d90c5477d75 [template_nginx_conf] _update_hash_filename_ = templates/nginx_conf.in md5sum = 61dc4c82bf48563228ce4dea6c5c6319 [template_launcher] _update_hash_filename_ = templates/launcher.in md5sum = 6cb0d64905ae7fc67277c1bf76b86875 [template_mime_types] _update_hash_filename_ = templates/mime_types.in md5sum = 4ef94a7b458d885cd79ba0b930a5727e [template_index_html] _update_hash_filename_ = templates/index.html.in md5sum = d57cb01df5941e139b02a2f7bdabcdc8 [template_graceful] _update_hash_filename_ = templates/graceful.in md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2 [template_instance_replicate] _update_hash_filename_ = instance_replicate.cfg.in md5sum = 7ff7e11d05145115f53564ec1af205ef slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/instance.cfg.in 0000664 0000000 0000000 00000004176 14134547230 0031265 0 ustar 00root root 0000000 0000000 [buildout] parts = switch-softwaretype eggs-directory = {{ buildout['eggs-directory'] }} develop-eggs-directory = {{ buildout['develop-eggs-directory'] }} offline = true [profile-common] nginx_location = {{ nginx_location }} dash_location = {{ dash_location }} template_nginx_conf = {{ template_nginx_conf_target }} template_mime_types = {{ template_mime_types_target }} template_launcher = {{ template_launcher_target }} template_index_html = {{ template_index_html_target }} template_graceful = {{ template_graceful_target }} template_monitor = {{ template_monitor }} [instance-html5as] recipe = slapos.recipe.template:jinja2 template = {{ template_instance_html5as_target }} rendered = ${buildout:directory}/${:filename} filename = instance-html5as.cfg context = section buildout buildout section parameter_list profile-common # partition_ipv6 is the random ipv6 allocated to the local partition key partition_ipv6 slap-configuration:ipv6-random # slapparameter_dict: dictionary of all parameters key slapparameter_dict slap-configuration:configuration jsonkey default_parameter_dict :default-parameters default-parameters = { "title": "", "download_url": null, "port": 8081, "monitor-httpd-port": 8197 } [instance-replicate] recipe = slapos.recipe.template:jinja2 extensions = jinja2.ext.do template = {{ template_instance_replicate }} rendered = ${buildout:directory}/${:filename} filename = instance-replicate-html5as.cfg context = section buildout buildout section parameter_list profile-common key slapparameter_dict slap-configuration:configuration jsonkey default_parameter_dict :default-parameters default-parameters = { "download_url": null, "replicate-quantity": 1 } [switch-softwaretype] recipe = slapos.cookbook:switch-softwaretype RootSoftwareInstance = ${:default} default = instance-html5as:rendered replicate = instance-replicate:rendered [slap-configuration] recipe = slapos.cookbook:slapconfiguration computer = ${slap-connection:computer-id} partition = ${slap-connection:partition-id} url = ${slap-connection:server-url} key = ${slap-connection:key-file} cert = ${slap-connection:cert-file} instance_html5as.cfg.in 0000664 0000000 0000000 00000017250 14134547230 0032640 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as ############################# # # Deploy html5as instance # ############################# # parameter_dict: a dictionary with the default parameters from instance.cfg.in # replaces the values with the parameters of the instance request if there are any {% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %} [buildout] parts = nginx_conf mime_types launcher nginx-graceful port-listening-promise logrotate-entry-nginx publish-connection-information # Define egg directories to be the one from Software Release # (/opt/slapgrid/...) # Always the same. eggs-directory = {{ buildout['eggs-directory'] }} develop-eggs-directory = {{ buildout['develop-eggs-directory'] }} offline = true # Instance profile extends monitoring stack extends = {{ parameter_list['template_monitor'] }} # partition tree # / # |- etc/ # | |- nginx.conf # | |- run/ # | |- html5as (binary) # |- var/ # | |- run/ # | | |- nginx.pid # | |- log/ # | | |- nginx.log # | | |- nginx.access.log # |- srv/ # | |- html5as/ (doc root) # | | |- index.html # | |- backup/ # Create all needed directories, depending on your needs [directory] recipe = slapos.cookbook:mkdirectory home = ${buildout:directory} etc = ${:home}/etc var = ${:home}/var srv = ${:home}/srv [basedirectory] recipe = slapos.cookbook:mkdirectory # Executables put here will be started but not monitored (for startup scripts) script = ${directory:etc}/run # Executables put here will be started and monitored (for daemons) service = ${directory:etc}/service log = ${directory:var}/log run = ${directory:var}/run backup = ${directory:srv}/backup [tempdirectory] recipe = slapos.cookbook:mkdirectory tmp = ${directory:home}/tmp client_body_temp_path = ${:tmp}/client_body_temp_path proxy_temp_path = ${:tmp}/proxy_temp_path fastcgi_temp_path = ${:tmp}/fastcgi_temp_path uwsgi_temp_path = ${:tmp}/uwsgi_temp_path scgi_temp_path = ${:tmp}/scgi_temp_path # List of options for html5as configuration # It will run a simple nginx serving the content of srv/html5as [html5as] # Options nb_workers = 2 # Network ip = {{ partition_ipv6 }} port = {{ parameter_dict['port'] }} access_url = http://[${:ip}]:${:port} # Paths # Log path_pid = ${basedirectory:run}/nginx.pid path_log = ${basedirectory:log}/nginx.log path_access_log = ${basedirectory:log}/nginx.access.log path_error_log = ${basedirectory:log}/nginx.error.log path_tmp = ${tempdirectory:tmp} # Docroot docroot = ${downloader:location} default_index = ${:docroot}/index.html # Config files path_nginx_conf = ${directory:etc}/nginx.conf path_mime_types = ${directory:etc}/mime_types # Binaries path_shell = {{ parameter_list['dash_location'] }}/bin/dash # Executables bin_launcher = ${basedirectory:service}/launcher # Utils path_nginx = {{ parameter_list['nginx_location'] }}/sbin/nginx # Render nginx conf [nginx_conf] recipe = slapos.recipe.template:jinja2 template = {{ parameter_list['template_nginx_conf'] }} rendered = ${html5as:path_nginx_conf} context = section param_html5as html5as section param_tempdir tempdirectory # Render necessary mime types file for nginx [mime_types] recipe = slapos.recipe.template:jinja2 template = {{ parameter_list['template_mime_types'] }} rendered = ${html5as:path_mime_types} # Render the script launching nginx [launcher] recipe = slapos.recipe.template:jinja2 template = {{ parameter_list['template_launcher'] }} rendered = ${html5as:bin_launcher} mode = 700 context = section param_html5as html5as # Command to put content in the docroot [downloader] recipe = slapos.recipe.build # Path where the recipe stores any produced file, # it will be automatically removed at the beginning of "install". location = ${directory:srv}/html5as # All the keys in this section will be available as a dict called "self.options" # We add: or '', otherwise jinja2 will render a 'None' string url = {{ parameter_dict['download_url'] or '' }} default_index_html = ${default_index_html:rendered} # If a tarball is passed as a parameter in download url # it's content will be served by the instance. # If the parameter is not provided it fallback to the default template install = import os, shutil buildout_offline = self.buildout['buildout']['offline'] try: # Allow to do self.download() which can only be used in "online" mode self.buildout['buildout']['offline'] = 'false' if self.options['url']: # Use fonctions from the slapos.recipe.build repository # Download a file from a URL to a temporary path file = self.download(self.options['url']) # Create a directory and extract the file that are compressed inside extract_dir = self.extract(file) # Return the right directory path workdir = guessworkdir(extract_dir) # Recursively copy directory self.copyTree(workdir, location) else: # Create directory and copy the default template inside os.makedirs(location) shutil.copy(self.options['default_index_html'], location) finally: # reset the parameter self.buildout['buildout']['offline'] = buildout_offline [default_index_html] recipe = slapos.recipe.template:jinja2 template = {{ parameter_list['template_index_html'] }} rendered = ${directory:srv}/index.html title = {{ parameter_dict['title'] }} context = key title :title ### Nginx Graceful [nginx-graceful] recipe = slapos.recipe.template:jinja2 template = {{ parameter_list['template_graceful'] }} rendered = ${basedirectory:script}/nginx-graceful mode = 0700 context = section param_html5as html5as # Port Listening checking promise [port-listening-promise] <= monitor-promise-base promise = check_socket_listening name = nginx-port-listening.py config-host = ${html5as:ip} config-port = ${html5as:port} # Use a port different from the default one in order to be able to # use it in a SlapOS webrunner or a Theia SlapOS Runner [monitor-instance-parameter] monitor-httpd-port = {{ parameter_dict['monitor-httpd-port'] }} # Monitor Stack also provides logrotate stack. We only need to extend # the logrotate-entry-base defined in instance-logrotate-base.cfg.in . # More parameters can be added following the logrotate-entry-base section [logrotate-entry-nginx] <= logrotate-entry-base name = nginx log = ${html5as:path_access_log} ${html5as:path_error_log} post = kill -USR1 $(cat ${html5as:path_pid}) # Publish nginx address [publish-connection-information] recipe = slapos.cookbook:publish # By extending monitor publish, all the section deploying monitoring will # be deployed. The parameters needed for accessing monitoring will be published <= monitor-publish server_url = ${html5as:access_url} title = Title {{ parameter_dict['title'] }}! # Add dependency to the promise so that frontend sections are processed # and there is no need to declare the new part in buildout:parts server-cdn-url = ${html5as-frontend-promise:url} # Request a CDN entry to master [html5as-frontend] # Extend slap-connnection to get the credentials for the request <= slap-connection # Recipe used to make requests recipe = slapos.cookbook:requestoptional name = HTML5AS frontend # Specify the software url of the frontend software release software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg # It is not a dedicated instance but an instance allocated on a shared instance slave = true config-url = ${html5as:access_url} config-https-only = true # The parameter expected to be received from the request are listed here. return = domain secure_access # Add a promise to make sure the cdn is properly configured [html5as-frontend-promise] <= monitor-promise-base promise = check_url_available name = html5as-http-frontend.py url = ${html5as-frontend:connection-secure_access} config-url = ${:url} instance_replicate.cfg.in 0000664 0000000 0000000 00000004374 14134547230 0033236 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as {%- set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %} {%- set replicate_quantity = int(parameter_dict['replicate-quantity']) %} # Set default title and port for each replicate based on requested quantity {%- for i in range(1, replicate_quantity + 1) %} {%- do parameter_dict.setdefault("title-%d" % i, "") %} {%- do parameter_dict.setdefault("port-%d" % i, 8081 + i) %} {%- do parameter_dict.setdefault("monitor-httpd-port-%d" % i, 8197 + i) %} {%- endfor %} # Standard buildout section [buildout] parts = publish-connection-information eggs-directory = {{ buildout['eggs-directory'] }} develop-eggs-directory = {{ buildout['develop-eggs-directory'] }} offline = true ################################ # Sections to Request instances ################################ # Macro section sharing request parameters [instance-request-base] <= slap-connection recipe = slapos.cookbook:request # It is the same software as the current one software-url = ${slap-connection:software-release-url} # We want the default behaviour software-type = default # What parameter are neede to be retrieved return = server_url server-cdn-url monitor-setup-url # Provided parameters # We add: or '', otherwise jinja2 will render a 'None' string config-download_url = {{ parameter_dict['download_url'] or '' }} # Create request section in a loop. {% for i in range(1, replicate_quantity + 1) %} # Request a normal html5as instance [instance-{{ i }}] <= instance-request-base # Name of the instance name = instance-html5as-{{ i }} config-port = {{ parameter_dict["port-%s" % i] }} config-title = {{ parameter_dict["title-%s" % i] }} config-monitor-httpd-port = {{ parameter_dict["monitor-httpd-port-%s" % i] }} {% if "sla-%s-computer-guid" % i in parameter_dict -%} sla-computer_guid = {{ parameter_dict["sla-%s-computer-guid" % i] }} {% endif -%} {% endfor %} # Publish information to connect to the two instances [publish-connection-information] recipe = slapos.cookbook:publish {% for i in range(1, replicate_quantity + 1) %} instance-{{ i }}-server_url = ${instance-{{ i }}:connection-server_url} instance-{{ i }}-server-cdn-url = ${instance-{{ i }}:connection-server-cdn-url} instance-{{ i }}-server-monitor-setup-url = ${instance-{{ i }}:connection-monitor-setup-url} {% endfor %} slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/software.cfg 0000664 0000000 0000000 00000005045 14134547230 0030702 0 ustar 00root root 0000000 0000000 [buildout] extends = # buildout.hash.cfg is used for automated hash calculation of managed # instance files by calling update-hash buildout.hash.cfg # "slapos" stack describes basic things needed for 99.9% of SlapOS Software # Releases ../../stack/slapos.cfg # Extend monitoring stack to provide necessary tools for monitoring ../../stack/monitor/buildout.cfg # Extend here component profiles, like openssl, apache, mariadb, curl... # Or/and extend a stack (lamp, tomcat) that does most of the work for you # In this example we extend needed components for html5as. ../../component/nginx/buildout.cfg ../../component/dash/buildout.cfg parts = # Call installation of slapos.cookbook egg defined in stack/slapos.cfg (needed # in 99,9% of Slapos Software Releases) slapos-cookbook # Call creation of instance.cfg file that will be called for deployment of # instance template-cfg # Download instance.cfg.in (buildout profile used to deployment of instance), # replace all {{ foo_bar }} parameters by real values # The recipe, template and mode are fetched from jijna-template [template-cfg] recipe = slapos.recipe.template:jinja2 rendered = ${buildout:directory}/template.cfg template = ${:_profile_base_location_}/${:filename} mode = 0644 context = section buildout buildout key nginx_location nginx:location key dash_location dash:location key template_nginx_conf_target template_nginx_conf:target key template_mime_types_target template_mime_types:target key template_launcher_target template_launcher:target key template_instance_html5as_target instance_html5as:target key template_index_html_target template_index_html:target key template_graceful_target template_graceful:target key template_instance_replicate template_instance_replicate:target # Monitor stack also provides a template for the instance key template_monitor monitor2-template:rendered # Have one shared section to define the default behaviour to download # templates. Sections inheriting from this one won't need to redefine # shared parameters [download-base] recipe = slapos.recipe.build:download url = ${:_profile_base_location_}/${:_update_hash_filename_} mode = 0644 # Download instance_html5as.cfg.in [instance_html5as] # This section inherit from download-base <= download-base # Filename and md5sum is defined in buildout.hash.cfg [template_nginx_conf] <= download-base [template_launcher] <= download-base [template_mime_types] <= download-base [template_index_html] <= download-base [template_graceful] <= download-base [template_instance_replicate] <= download-base slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates/ 0000775 0000000 0000000 00000000000 14134547230 0030361 5 ustar 00root root 0000000 0000000 graceful.in 0000664 0000000 0000000 00000000316 14134547230 0032422 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates #! {{ param_html5as['path_shell'] }} # BEWARE: This file is operated by slapos node # BEWARE: It will be overwritten automatically # Run graceful exec kill -s SIGHUP $(cat {{ param_html5as['path_pid'] }}) index.html.in 0000664 0000000 0000000 00000000103 14134547230 0032676 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates {% if title %}
Hello World
launcher.in 0000664 0000000 0000000 00000000341 14134547230 0032431 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates #! {{ param_html5as['path_shell'] }} # BEWARE: This file is operated by slapos node # BEWARE: It will be overwritten automatically # Run nginx exec {{ param_html5as['path_nginx'] }} -c {{ param_html5as['path_nginx_conf'] }} mime_types.in 0000664 0000000 0000000 00000004013 14134547230 0033003 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates types { text/html html htm shtml; text/css css; text/xml xml rss; image/gif gif; image/jpeg jpeg jpg; application/x-javascript js; application/atom+xml atom; text/mathml mml; text/plain txt; text/vnd.sun.j2me.app-descriptor jad; text/vnd.wap.wml wml; text/x-component htc; image/png png; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; image/svg+xml svg svgz; application/java-archive jar war ear; application/mac-binhex40 hqx; application/msword doc; application/pdf pdf; application/postscript ps eps ai; application/rtf rtf; application/vnd.ms-excel xls; application/vnd.ms-powerpoint ppt; application/vnd.wap.wmlc wmlc; application/vnd.google-earth.kml+xml kml; application/vnd.google-earth.kmz kmz; application/x-7z-compressed 7z; application/x-cocoa cco; application/x-java-archive-diff jardiff; application/x-java-jnlp-file jnlp; application/x-makeself run; application/x-perl pl pm; application/x-pilot prc pdb; application/x-rar-compressed rar; application/x-redhat-package-manager rpm; application/x-sea sea; application/x-shockwave-flash swf; application/x-stuffit sit; application/x-tcl tcl tk; application/x-x509-ca-cert der pem crt; application/x-xpinstall xpi; application/xhtml+xml xhtml; application/zip zip; application/octet-stream bin exe dll; application/octet-stream deb; application/octet-stream dmg; application/octet-stream eot; application/octet-stream iso img; application/octet-stream msi msp msm; application/ogg ogx; audio/midi mid midi kar; audio/mpeg mpga mpega mp2 mp3 m4a; audio/ogg oga ogg spx; audio/x-realaudio ra; audio/webm weba; video/3gpp 3gpp 3gp; video/mp4 mp4; video/mpeg mpeg mpg mpe; video/ogg ogv; video/quicktime mov; video/webm webm; video/x-flv flv; video/x-mng mng; video/x-ms-asf asx asf; video/x-ms-wmv wmv; video/x-msvideo avi; } nginx_conf.in 0000664 0000000 0000000 00000001720 14134547230 0032762 0 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/templates worker_processes {{ param_html5as['nb_workers'] }}; pid {{ param_html5as['path_pid'] }}; error_log {{ param_html5as['path_error_log'] }}; daemon off; events { worker_connections 1024; accept_mutex off; } http { include {{ param_html5as['path_mime_types'] }}; default_type application/octet-stream; types_hash_bucket_size 64; access_log {{ param_html5as['path_access_log'] }} combined; index index.html; server { listen [{{ param_html5as['ip'] }}]:{{ param_html5as['port'] }}; server_name _; keepalive_timeout 5; client_body_temp_path {{ param_tempdir['client_body_temp_path'] }}; proxy_temp_path {{ param_tempdir['proxy_temp_path'] }}; fastcgi_temp_path {{ param_tempdir['fastcgi_temp_path'] }}; uwsgi_temp_path {{ param_tempdir['uwsgi_temp_path'] }}; scgi_temp_path {{ param_tempdir['scgi_temp_path'] }}; # path for static files root {{ param_html5as['docroot'] }}; } } slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/test/ 0000775 0000000 0000000 00000000000 14134547230 0027342 5 ustar 00root root 0000000 0000000 slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/test/README.md 0000664 0000000 0000000 00000000043 14134547230 0030616 0 ustar 00root root 0000000 0000000 Tests for html5as software release slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/test/setup.py 0000664 0000000 0000000 00000003652 14134547230 0031062 0 ustar 00root root 0000000 0000000 ############################################################################## # # Copyright (c) 2019 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsibility of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # guarantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## from setuptools import setup, find_packages version = '0.0.1.dev0' name = 'slapos.test.html5as' with open("README.md") as f: long_description = f.read() setup( name=name, version=version, description="Test for SlapOS' HTML5AS", long_description=long_description, long_description_content_type='text/markdown', maintainer="Nexedi", maintainer_email="info@nexedi.com", url="https://lab.nexedi.com/nexedi/slapos", packages=find_packages(), install_requires=[ 'slapos.core', 'slapos.libnetworkcache', 'erp5.util', 'requests', ], zip_safe=True, test_suite='test', ) slapos-ae722678a1b51b525863b7a2d8e6a936e8dc7f31-software-html5as/software/html5as/test/test.py 0000664 0000000 0000000 00000014344 14134547230 0030701 0 ustar 00root root 0000000 0000000 ############################################################################## # # Copyright (c) 2021 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsibility of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # guarantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## import os import requests from urlparse import urlparse from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( os.path.abspath( os.path.join(os.path.dirname(__file__), '..', 'software.cfg'))) class HTML5ASTestCase(SlapOSInstanceTestCase): """ Common class for testing html5as. It inherit from SlapOSInstanceTestCase which: * Install the software release. * Checks it compile without issue. * Deploy the instance * Check deployement works and promise pass For testing the deployement a different testing class will need to be set up per each variation of parameters the instance needs to be given. """ def checkUrlAndGetResponse(self, url): """ Common class to check an url and return the response """ response = requests.get(url) self.assertEqual(requests.codes['OK'], response.status_code) return response class TestEmptyDeploy(HTML5ASTestCase): """ This class test the instance with no parameters. """ def test_deploy_with_no_paramater(self): url = self.requestDefaultInstance().getConnectionParameterDict()['server_url'] response = self.checkUrlAndGetResponse(url) result = response.text self.assertFalse("Hello World
" in result) class TestDeployWithTitle(HTML5ASTestCase): """ This class test an instance with the parameter "title" """ @classmethod def getInstanceParameterDict(cls): return { 'title': 'Test1', } def test_deploy_with_title_parameter(self): connection_parameter_dict = self.computer_partition.getConnectionParameterDict() self.assertEqual(connection_parameter_dict["title"], "Title Test1!") url = connection_parameter_dict['server_url'] response = self.checkUrlAndGetResponse(url) result = response.text self.assertTrue("Hello World
" in result) class TestGracefulWithPortChange(HTML5ASTestCase): """ This class test the instance with the parameter "port" """ instance_parameter_dict = { 'port': 8087 } @classmethod def getInstanceParameterDict(cls): return cls.instance_parameter_dict def test_change_port_parameter(self): """ This test test port change and its application with graceful restart """ # Check initial connection parameter match expected port url = self.computer_partition.getConnectionParameterDict()['server_url'] self.assertEqual(urlparse(url).port, 8087) # Check port is listening even thought it is duplicated with the promise: # "port-listening-promise" self.checkUrlAndGetResponse(url) # Update port parameter self.instance_parameter_dict.update({ 'port': 8086, }) # Request instance with the new port parameter self.requestDefaultInstance() # Reprocess the instance to apply new port and run promises self.slap.waitForInstance(self.instance_max_retry) # Rerequest instance to get update connection parameter url = self.requestDefaultInstance().getConnectionParameterDict()['server_url'] # Make sure the new port is the one being used self.assertEqual(urlparse(url).port, 8086) # Check port is listening even thought it is duplicated with the promise: # "port-listening-promise" self.checkUrlAndGetResponse(url) class TestReplicateHTML5AS(HTML5ASTestCase): """ This class test the instance with the parameter "port" """ instance_parameter_dict = { "port-1": 8088, "title-1": "Title 1", } @classmethod def getInstanceSoftwareType(cls): return 'replicate' @classmethod def getInstanceParameterDict(cls): return cls.instance_parameter_dict def test_replicate_instance(self): # Check First instance is deployed with proper parameters connection_parameter_dict = self.computer_partition.getConnectionParameterDict() url = connection_parameter_dict['instance-1-server_url'] self.assertEqual(urlparse(url).port, 8088) response = self.checkUrlAndGetResponse(url) result = response.text self.assertTrue("