Squashed 'tools/' changes from 1fc4d66..3ec519f

3ec519f Merge pull request #12 from weaveworks/prefix-unit-test-sched
856790f Use golang package name as a prefix on unit test schedules.
7f5fa57 Merge pull request #11 from weaveworks/10-dont-delete-sshed-gce-nodes
0bff9b4 Don't delete GCE nodes for running (but failed) builds
03aed8f Merge pull request #9 from weaveworks/configure-pac-domain
c04c534 socks: Make main shExpMatch expression configurable

git-subtree-dir: tools
git-subtree-split: 3ec519f704
This commit is contained in:
Tom Wilkie
2015-12-07 14:53:05 +00:00
parent c0f3a59726
commit a7eef92988
3 changed files with 16 additions and 6 deletions

View File

@@ -96,7 +96,7 @@ def gc():
headers={'Accept': 'application/json'})
assert result.status_code == 200
builds = json.loads(result.content)
running = {build['build_num'] for build in builds if build['status'] == 'running'}
running = {build['build_num'] for build in builds if not build.get('stop_time')}
logging.info("Runnings builds: %r", running)
# Stop VMs for builds that aren't running

View File

@@ -13,13 +13,18 @@ import (
"github.com/weaveworks/weave/common/mflagext"
)
type pacFileParameters struct {
HostMatch string
Aliases map[string]string
}
const (
pacfile = `
function FindProxyForURL(url, host) {
if(shExpMatch(host, "*.weave.local")) {
if(shExpMatch(host, "{{.HostMatch}}")) {
return "SOCKS5 localhost:8000";
}
{{range $key, $value := .}}
{{range $key, $value := .Aliases}}
if (host == "{{$key}}") {
return "SOCKS5 localhost:8000";
}
@@ -30,8 +35,12 @@ function FindProxyForURL(url, host) {
)
func main() {
var as []string
var (
as []string
hostMatch string
)
mflagext.ListVar(&as, []string{"a", "-alias"}, []string{}, "Specify hostname aliases in the form alias:hostname. Can be repeated.")
mflag.StringVar(&hostMatch, []string{"h", "-host-match"}, "*.weave.local", "Specify main host shExpMatch expression in pacfile")
mflag.Parse()
var aliases = map[string]string{}
@@ -50,7 +59,7 @@ func main() {
t := template.Must(template.New("pacfile").Parse(pacfile))
http.HandleFunc("/proxy.pac", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/x-ns-proxy-autoconfig")
t.Execute(w, aliases)
t.Execute(w, pacFileParameters{hostMatch, aliases})
})
if err := http.ListenAndServe(":8080", nil); err != nil {

3
test
View File

@@ -50,7 +50,8 @@ TESTDIRS=$(find . -type f -name '*_test.go' | xargs -n1 dirname | grep -vE '^\./
# If running on circle, use the scheduler to work out what tests to run on what shard
if [ -n "$CIRCLECI" -a -z "$NO_SCHEDULER" -a -x "$DIR/sched" ]; then
TESTDIRS=$(echo $TESTDIRS | "$DIR/sched" sched units-$CIRCLE_BUILD_NUM $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX)
PREFIX=$(go list -e ./ | sed -e 's/\//-/g')
TESTDIRS=$(echo $TESTDIRS | "$DIR/sched" sched $PREFIX-$CIRCLE_BUILD_NUM $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX)
echo $TESTDIRS
fi