Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/239504

Change subject: toolschecker:  Add tests for starting/stopping web services
......................................................................

toolschecker:  Add tests for starting/stopping web services

Change-Id: If42fd5b999fb4a90e18ef8a358bad7e662af539b
---
A modules/toollabs/files/toolschecker-generic-service.py
A modules/toollabs/files/toolschecker-lighttpd-service.php
M modules/toollabs/files/toolschecker.py
M modules/toollabs/manifests/checker.pp
4 files changed, 83 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/04/239504/1

diff --git a/modules/toollabs/files/toolschecker-generic-service.py 
b/modules/toollabs/files/toolschecker-generic-service.py
new file mode 100644
index 0000000..84a31c8
--- /dev/null
+++ b/modules/toollabs/files/toolschecker-generic-service.py
@@ -0,0 +1,8 @@
+import flask
+
+app = flask.Flask(__name__)
+
[email protected]('/')
+def index():
+    return 'Python works!'
+
diff --git a/modules/toollabs/files/toolschecker-lighttpd-service.php 
b/modules/toollabs/files/toolschecker-lighttpd-service.php
new file mode 100644
index 0000000..18220ce
--- /dev/null
+++ b/modules/toollabs/files/toolschecker-lighttpd-service.php
@@ -0,0 +1,2 @@
+<?php
+echo "Lighttpd works";
diff --git a/modules/toollabs/files/toolschecker.py 
b/modules/toollabs/files/toolschecker.py
index f69a919..857a1c8 100644
--- a/modules/toollabs/files/toolschecker.py
+++ b/modules/toollabs/files/toolschecker.py
@@ -269,6 +269,60 @@
     return False
 
 
+@check('/service/start/lighttpd')
+def service_start_lighttpd():
+    ''' Start a simple web service, verify that it can serve a page
+        within 10 seconds.'''
+    success = False
+    url = "https://tools.wmflabs.org/toolschecker/";
+    with open(os.devnull, 'w') as devnull:
+        subprocess.check_call(['/usr/local/bin/webservice', 'start'],
+                              stderr=devnull, stdout=devnull)
+
+    for i in range(0, 10):
+        request = requests.get(url)
+        if request.status_code == 200:
+            success = True
+            break
+
+    with open(os.devnull, 'w') as devnull:
+        subprocess.check_call(['/usr/local/bin/webservice', 'stop'],
+                              stderr=devnull, stdout=devnull)
+
+    # Make sure it really stopped
+    request = requests.get(url)
+    if request.status_code == 200:
+        success = False
+
+    return success
+
+
+@check('/service/start/generic')
+def service_start_generic():
+    success = False
+    url = "https://tools.wmflabs.org/toolschecker/";
+    with open(os.devnull, 'w') as devnull:
+        subprocess.check_call(['/usr/local/bin/webservice2', 'uwsgi-python', 
'start'],
+                              stderr=devnull, stdout=devnull)
+
+    for i in range(0, 10):
+        request = requests.get(url)
+        if request.status_code == 200:
+            success = True
+            break
+
+    with open(os.devnull, 'w') as devnull:
+        subprocess.check_call(['/usr/local/bin/webservice2', 'uwsgi-python', 
'stop'],
+                              stderr=devnull, stdout=devnull)
+
+    # Make sure it really stopped
+    request = requests.get(url)
+    if request.status_code == 200:
+        success = False
+
+    return success
+
+
 @check('/self')
 def self_check():
     return True
diff --git a/modules/toollabs/manifests/checker.pp 
b/modules/toollabs/manifests/checker.pp
index 9141261..5afb828 100644
--- a/modules/toollabs/manifests/checker.pp
+++ b/modules/toollabs/manifests/checker.pp
@@ -8,7 +8,7 @@
 # idmapd related issues.
 class toollabs::checker inherits toollabs {
     include toollabs::infrastructure
-    include gridengine::submit_host
+    include toollabs::submit
 
     require_package('python-flask', 'python-redis',
                     'uwsgi', 'uwsgi-plugin-python',
@@ -23,6 +23,24 @@
         notify => Service['toolschecker'],
     }
 
+    file { '/data/project/toolschecker/www/python/src/app.py':
+        ensure => file,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 'puppet:///modules/toollabs/toolschecker_generic_service.py',
+        notify => Service['toolschecker'],
+    }
+
+    file { '/data/project/toolschecker/public_html/index.php':
+        ensure => file,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 
'puppet:///modules/toollabs/toolschecker_lighttpd_service.php',
+        notify => Service['toolschecker'],
+    }
+
     file { ['/run/toolschecker', '/var/lib/toolschecker', 
'/var/lib/toolschecker/puppetcerts']:
         ensure => directory,
         owner  => "${::labsproject}.toolschecker",

-- 
To view, visit https://gerrit.wikimedia.org/r/239504
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If42fd5b999fb4a90e18ef8a358bad7e662af539b
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to