mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Test startup checks for serve command
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if unix.Access(context.Config().RootDir, unix.W_OK) != nil {
|
if unix.Access(context.Config().RootDir, unix.W_OK) != nil {
|
||||||
return fmt.Errorf("Configured rootDir '%s' inaccesible, check access rights", context.Config().RootDir)
|
return fmt.Errorf("Configured rootDir '%s' is inaccessible, check access rights", context.Config().RootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
listen := context.Flags().Lookup("listen").Value.String()
|
listen := context.Flags().Lookup("listen").Value.String()
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ func aptlyServe(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if unix.Access(context.Config().RootDir, unix.W_OK) != nil {
|
if unix.Access(context.Config().RootDir, unix.W_OK) != nil {
|
||||||
return fmt.Errorf("Configured rootDir '%s' inaccesible, check access rights", context.Config().RootDir)
|
return fmt.Errorf("Configured rootDir '%s' is inaccessible, check access rights", context.Config().RootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if context.CollectionFactory().PublishedRepoCollection().Len() == 0 {
|
if context.CollectionFactory().PublishedRepoCollection().Len() == 0 {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ERROR: Configured rootDir '/rootDir/does/not/exist' is inaccessible, check access rights
|
||||||
@@ -8,8 +8,40 @@ import signal
|
|||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import time
|
import time
|
||||||
|
import errno
|
||||||
|
|
||||||
from lib import BaseTest
|
from lib import BaseTest
|
||||||
|
from socket import error as socket_error
|
||||||
|
|
||||||
|
class RootDirInaccessible(BaseTest):
|
||||||
|
"""
|
||||||
|
serve command aborts if rootDir is inaccessible
|
||||||
|
"""
|
||||||
|
fixtureDB = False
|
||||||
|
fixturePool = False
|
||||||
|
configOverride = { "rootDir": "/rootDir/does/not/exist" }
|
||||||
|
runCmd = "aptly serve -listen=127.0.0.1:8765"
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
proc = subprocess.Popen(shlex.split(self.runCmd), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, bufsize=0)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
conn = httplib.HTTPConnection("127.0.0.1", 8765)
|
||||||
|
conn.request("GET", "/")
|
||||||
|
r = conn.getresponse()
|
||||||
|
self.http_response = r.read()
|
||||||
|
output = os.read(proc.stdout.fileno(), 8192)
|
||||||
|
|
||||||
|
except socket_error as serr:
|
||||||
|
if serr.errno != errno.ECONNREFUSED:
|
||||||
|
raise serr
|
||||||
|
|
||||||
|
finally:
|
||||||
|
self.output, err = proc.communicate()
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
self.check_output()
|
||||||
|
|
||||||
|
|
||||||
class Serve1Test(BaseTest):
|
class Serve1Test(BaseTest):
|
||||||
|
|||||||
Reference in New Issue
Block a user