Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/blobs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
golang-windows/go1.7.4.windows-amd64.zip:
size: 90409580
sha: a0da2f5d67e5b800eba811a34ca4b2aa22cca678
golang/go1.6.2.linux-amd64.tar.gz:
size: 84840658
object_id: f1833f76-ad8b-4bef-55cd-a9fab4441299
Expand All @@ -6,3 +9,6 @@ stress/stress-1.0.4.tar.gz:
size: 191800
object_id: 8c4a0c3b-348e-4367-8e2b-8c2742c5db79
sha: e1533bc704928ba6e26a362452e6db8fd58b1f0b
stress/stress-windows-1.0.4.zip:
size: 1275268
sha: 45117dada9dcf3982759e163632c4c6669fbdeb5
9 changes: 9 additions & 0 deletions jobs/turbulence_agent_windows/monit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"processes": [
{
"name": "turbulence-windows",
"executable": "/var/vcap/packages/turbulence-windows/bin/agent.exe",
"args": [ "-configPath", "/var/vcap/jobs/turbulence_agent_windows/config/config.json" ]
}
]
}
20 changes: 20 additions & 0 deletions jobs/turbulence_agent_windows/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: turbulence_agent_windows

templates:
ca_cert.erb: config/ca_cert
config.json.erb: config/config.json
pre-start.ps1.erb: bin/pre-start.ps1

packages:
- turbulence-windows
- stress-windows

consumes:
- name: api
type: turbulence_api

properties:
debug:
description: "Show debug logs"
default: true
1 change: 1 addition & 0 deletions jobs/turbulence_agent_windows/templates/ca_cert.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= link("api").p("cert.ca") %>
17 changes: 17 additions & 0 deletions jobs/turbulence_agent_windows/templates/config.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%=

api = link("api")

JSON.dump(
"AgentID" => "_agent_id_",

"API" => {
"Host" => api.instances.first.address,
"Port" => api.p("listen_port"),
"CACert" => api.p("cert.ca"),
"Username" => api.p("username"),
"Password" => api.p("password"),
},
)

%>
26 changes: 26 additions & 0 deletions jobs/turbulence_agent_windows/templates/pre-start.ps1.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$ErrorActionPreference = "Stop";
trap { $host.SetShouldExit(1) }

$SETTINGS_FILE = "C:\var\vcap\bosh\settings.json"
$CONFIG_FILE = "C:\var\vcap\jobs\turbulence_agent_windows\config\config.json"

try {
$vmID = (Get-Content -Raw $SETTINGS_FILE | ConvertFrom-Json).agent_id

$config = (Get-Content -Raw $CONFIG_FILE | ConvertFrom-Json)
$config.AgentID = $vmID

$config | ConvertTo-Json | Set-Content $CONFIG_FILE
} catch {
Write-Error $_.Exception.Message
Exit 1
}

$REG_KEY='Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment'
$oldpath = (Get-ItemProperty -Path $REG_KEY -Name PATH).path
$newpath = "${oldpath};C:\var\vcap\packages\stress-windows"
Set-ItemProperty -Path $REG_KEY -Name PATH -Value $newpath

SETX /M PATH $newpath

Exit 0
17 changes: 17 additions & 0 deletions packages/golang-windows/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$path="golang-windows/go1.7.4.windows-amd64.zip"

try {
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip {
param([string]$zipfile, [string]$outpath)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Unzip "${path}" "${env:BOSH_INSTALL_TARGET}"
} catch {
Write-Error $_.Exception.Message
Exit 1
}

Exit 0
7 changes: 7 additions & 0 deletions packages/golang-windows/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: golang-windows

dependencies: []

files:
- golang-windows/go1.7.4.windows-amd64.zip
16 changes: 16 additions & 0 deletions packages/stress-windows/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ErrorActionPreference = "Stop";
trap { $host.SetShouldExit(1) }

$STRESS_ZIP = "stress/stress-windows-1.0.4.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem

function Unzip
{
param([string]$zipfile, [string]$outpath)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Unzip "${STRESS_ZIP}" "${env:BOSH_INSTALL_TARGET}"
Exit 0

5 changes: 5 additions & 0 deletions packages/stress-windows/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: stress-windows

files:
- stress/stress-windows-1.0.4.zip
32 changes: 32 additions & 0 deletions packages/turbulence-windows/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
try {
$BOSH_INSTALL_TARGET = Resolve-Path "${env:BOSH_INSTALL_TARGET}"

$env:GOROOT="C:\var\vcap\packages\golang-windows\go"
$env:GOPATH="${PWD}"
$env:PATH="${env:GOROOT}\bin;${env:PATH}"
$env:GO15VENDOREXPERIMENT=1

New-Item -Type directory -Path "..\src" -Force
Copy-Item -Recurse -Path "*" -Destination "..\src" -Force
Move-Item -Path "..\src" -Destination ".\src"

go.exe build -o "${BOSH_INSTALL_TARGET}/bin/api.exe" github.com/cppforlife/turbulence/main
if ($LASTEXITCODE -ne 0) {
Write-Error "Error: compiling: github.com/cppforlife/turbulence/main"
Exit $LASTEXITCODE
}

go.exe build -o "${BOSH_INSTALL_TARGET}/bin/agent.exe" github.com/cppforlife/turbulence/agent
if ($LASTEXITCODE -ne 0) {
Write-Error "Error: compiling: github.com/cppforlife/turbulence/agent"
Exit $LASTEXITCODE
}

Copy-Item -Recurse -Path "src/github.com/cppforlife/turbulence/public" -Destination "${BOSH_INSTALL_TARGET}"
Copy-Item -Recurse -Path "src/github.com/cppforlife/turbulence/templates" -Destination "${BOSH_INSTALL_TARGET}"
} catch {
Write-Error $_.Exception.Message
Exit 1
}

Exit 0
10 changes: 10 additions & 0 deletions packages/turbulence-windows/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: turbulence-windows

dependencies:
- golang-windows

files:
- "**/*.go"
- github.com/cppforlife/turbulence/public/**/*
- github.com/cppforlife/turbulence/templates/**/*
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package agentreqs

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package agentreqs

import (
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)

// TODO (CEV): Refactor so that we don't duplicate the unix type definition.
//
// See http://www.linuxfoundation.org/collaborate/workgroups/networking/netem
type ControlNetOptions struct {
Type string
Timeout string // Times may be suffixed with ms,s,m,h

// slow: tc qdisc add dev eth0 root netem delay 50ms 10ms distribution normal
Delay string
DelayVariation string

// flaky: tc qdisc add dev eth0 root netem loss 20% 75%
Loss string
LossCorrelation string

// reset: tc qdisc del dev eth0 root
}

type ControlNetTask struct {
cmdRunner boshsys.CmdRunner
opts ControlNetOptions
logger boshlog.Logger
}

func NewControlNetTask(cmdRunner boshsys.CmdRunner, opts ControlNetOptions, logger boshlog.Logger) ControlNetTask {
return ControlNetTask{cmdRunner: cmdRunner, opts: opts, logger: logger}
}

func (t ControlNetTask) Execute() error {
t.logger.Info("ControlNetTask", "Not implemented on Windows")
return nil
}
26 changes: 0 additions & 26 deletions src/github.com/cppforlife/turbulence/agentreqs/fill_disk_task.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package agentreqs

import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
Expand All @@ -23,28 +22,3 @@ type FillDiskTask struct {
func NewFillDiskTask(cmdRunner boshsys.CmdRunner, opts FillDiskOptions, _ boshlog.Logger) FillDiskTask {
return FillDiskTask{cmdRunner, opts}
}

func (t FillDiskTask) Execute() error {
if t.opts.Persistent {
return t.fill("/var/vcap/store/.filler")
}

if t.opts.Ephemeral {
return t.fill("/var/vcap/data/.filler")
}

if t.opts.Temporary {
return t.fill("/tmp/.filler")
}

return t.fill("/.filler")
}

func (t FillDiskTask) fill(path string) error {
_, _, _, err := t.cmdRunner.RunCommand("dd", "if=/dev/zero", "of="+path, "bs=1M")
if err != nil {
return bosherr.WrapError(err, "Filling disk")
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// +build !windows

package agentreqs

import bosherr "github.com/cloudfoundry/bosh-utils/errors"

func (t FillDiskTask) Execute() error {
if t.opts.Persistent {
return t.fill("/var/vcap/store/.filler")
}

if t.opts.Ephemeral {
return t.fill("/var/vcap/data/.filler")
}

if t.opts.Temporary {
return t.fill("/tmp/.filler")
}

return t.fill("/.filler")
}

func (t FillDiskTask) fill(path string) error {
_, _, _, err := t.cmdRunner.RunCommand("dd", "if=/dev/zero", "of="+path, "bs=1M")
if err != nil {
return bosherr.WrapError(err, "Filling disk")
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package agentreqs

import (
"os"
"path/filepath"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
)

func (t FillDiskTask) Execute() error {
if t.opts.Persistent {
return t.fill("/var/vcap/store/.filler")
}

if t.opts.Ephemeral {
return t.fill("/var/vcap/data/.filler")
}

if t.opts.Temporary {
return t.fill(filepath.Join(os.TempDir(), ".filler"))
}

return t.fill("/.filler")
}

func (t FillDiskTask) fill(path string) error {
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
if err != nil {
return bosherr.WrapError(err, "Filling disk")
}
defer f.Close()

zero := make([]byte, 1024*1024)
var werr error
for {
if _, werr = f.Write(zero); werr != nil {
break
}
}
return bosherr.WrapError(werr, "Filling disk")
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package agentreqs

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package agentreqs

import (
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)

type FirewallOptions struct {
Type string
Timeout string // Times may be suffixed with ms,s,m,h

BlockBOSHAgent bool
}

type FirewallTask struct {
cmdRunner boshsys.CmdRunner
opts FirewallOptions

allowedOutputDest []FirewallTaskDest
logger boshlog.Logger
}

type FirewallTaskDest struct {
Host string
Port int

IsBOSHMbus bool
}

func NewFirewallTask(
cmdRunner boshsys.CmdRunner,
opts FirewallOptions,
allowedOutputDest []FirewallTaskDest,
logger boshlog.Logger,
) FirewallTask {
return FirewallTask{cmdRunner, opts, allowedOutputDest, logger}
}

func (t FirewallTask) Execute() error {
t.logger.Info("FirewallTask", "not implemented on Windows")
return nil
}
Loading