recwatch: Fix watching newly created files on macOS
Fixes: https://github.com/purpleidea/mgmt/issues/33
This commit is contained in:
committed by
James Shubin
parent
318fe4a5dc
commit
9544ab2e02
@@ -134,9 +134,8 @@ discouraged either). Meaning it might work but in the case it doesn't you would
|
|||||||
have to provide your own patches to fix problems (the project maintainer and
|
have to provide your own patches to fix problems (the project maintainer and
|
||||||
community are glad to assist where needed).
|
community are glad to assist where needed).
|
||||||
|
|
||||||
There are currently some issues that make `mgmt` less suitable to run for
|
There are currently some issues that make `mgmt` less suitable to run for provisioning
|
||||||
provisioning macOS (eg: [https://github.com/purpleidea/mgmt/issues/33](https://github.com/purpleidea/mgmt/issues/33)).
|
macOS. But as a client to provision remote servers it should run fine.
|
||||||
But as a client to provision remote servers it should run fine.
|
|
||||||
|
|
||||||
Since the primary supported systems are Linux and these are the environments
|
Since the primary supported systems are Linux and these are the environments
|
||||||
tested for it is wise to run these suites during macOS development as well. To
|
tested for it is wise to run these suites during macOS development as well. To
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ if [ ! -z "$APT" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$BREW" ]; then
|
if [ ! -z "$BREW" ]; then
|
||||||
# coreutils contains gtimeout
|
# coreutils contains gtimeout, gstat, etc
|
||||||
$BREW install libvirt augeas coreutils || true
|
$BREW install libvirt augeas coreutils || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ func (obj *RecWatcher) Watch() error {
|
|||||||
if obj.Flags.Debug {
|
if obj.Flags.Debug {
|
||||||
log.Printf("watcher.Add(%s): Error: %v", current, err)
|
log.Printf("watcher.Add(%s): Error: %v", current, err)
|
||||||
}
|
}
|
||||||
|
// ENOENT for linux, etc and IsNotExist for macOS
|
||||||
if err == syscall.ENOENT {
|
if err == syscall.ENOENT || os.IsNotExist(err) {
|
||||||
index-- // usually not found, move up one dir
|
index-- // usually not found, move up one dir
|
||||||
index = int(math.Max(1, float64(index)))
|
index = int(math.Max(1, float64(index)))
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
|
||||||
# https://github.com/purpleidea/mgmt/issues/33
|
|
||||||
echo "This test is broken on macOS, skipping!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
. ../util.sh
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$timeout --kill-after=60s 55s "$MGMT" run --yaml file-mode.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
$timeout --kill-after=60s 55s "$MGMT" run --yaml file-mode.yaml --converged-timeout=5 --no-watch --tmp-prefix &
|
||||||
pid=$!
|
pid=$!
|
||||||
@@ -19,7 +15,7 @@ ls -l /tmp/mgmt
|
|||||||
test -e /tmp/mgmt/f1
|
test -e /tmp/mgmt/f1
|
||||||
test -e /tmp/mgmt/f2
|
test -e /tmp/mgmt/f2
|
||||||
test -e /tmp/mgmt/f3
|
test -e /tmp/mgmt/f3
|
||||||
test $(stat -c%a /tmp/mgmt/f2) = 741
|
test $($STAT -c%a /tmp/mgmt/f2) = 741
|
||||||
test $(stat -c%a /tmp/mgmt/f3) = 614
|
test $($STAT -c%a /tmp/mgmt/f3) = 614
|
||||||
|
|
||||||
exit $e
|
exit $e
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
|
||||||
# https://github.com/purpleidea/mgmt/issues/33
|
|
||||||
echo "This test is broken on macOS, skipping!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p /tmp/mgmt/
|
mkdir -p /tmp/mgmt/
|
||||||
rm /tmp/mgmt/f1 || true
|
rm /tmp/mgmt/f1 || true
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
if env | grep -q -e '^TRAVIS=true$' && [[ $(uname) == "Darwin" ]]; then
|
if env | grep -q -e '^TRAVIS=true$'; then
|
||||||
# loadavg glibc calls don't seem to work properly on osx OS in travis
|
# loadavg glibc calls don't seem to work properly on osx OS in travis
|
||||||
echo "Travis and Jenkins give wonky results here, skipping test!"
|
echo "Travis and Jenkins give wonky results here, skipping test!"
|
||||||
exit
|
exit
|
||||||
@@ -18,9 +18,6 @@ regex="load average: [0-9]\,[0-9]{3,}, [0-9]\,[0-9]{3,}, [0-9]\,[0-9]{3,}"
|
|||||||
|
|
||||||
tmpdir="$($mktemp --tmpdir -d tmp.XXX)"
|
tmpdir="$($mktemp --tmpdir -d tmp.XXX)"
|
||||||
|
|
||||||
# macOS workaround https://github.com/purpleidea/mgmt/issues/33
|
|
||||||
touch "$tmpdir/loadavg"
|
|
||||||
|
|
||||||
cat > "$tmpdir/load0.mcl" <<EOF
|
cat > "$tmpdir/load0.mcl" <<EOF
|
||||||
\$theload = load()
|
\$theload = load()
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
|
||||||
# https://github.com/purpleidea/mgmt/issues/33
|
|
||||||
echo "This test is broken on macOS, skipping!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# run a graph, with prometheus support
|
# run a graph, with prometheus support
|
||||||
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-3.yaml &
|
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-3.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
#!/bin/bash -xe
|
#!/bin/bash -xe
|
||||||
|
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
|
||||||
# https://github.com/purpleidea/mgmt/issues/33
|
|
||||||
echo "This test is broken on macOS, skipping!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# run a graph, with prometheus support
|
# run a graph, with prometheus support
|
||||||
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-4.yaml &
|
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-4.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ export MGMT="$ROOT/mgmt"
|
|||||||
if [[ $(uname) == "Darwin" ]] ; then
|
if [[ $(uname) == "Darwin" ]] ; then
|
||||||
export timeout="gtimeout"
|
export timeout="gtimeout"
|
||||||
export mktemp="gmktemp"
|
export mktemp="gmktemp"
|
||||||
|
export STAT="gstat"
|
||||||
else
|
else
|
||||||
export timeout="timeout"
|
export timeout="timeout"
|
||||||
export mktemp="mktemp"
|
export mktemp="mktemp"
|
||||||
|
export STAT="stat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fail_test()
|
fail_test()
|
||||||
|
|||||||
Reference in New Issue
Block a user