Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:taskcluster/taskcluster-worker in…
Browse files Browse the repository at this point in the history
…to http-server
  • Loading branch information
jonasfj committed Mar 8, 2016
2 parents f8ebef0 + 2130156 commit 64f7bf3
Show file tree
Hide file tree
Showing 23 changed files with 135 additions and 132 deletions.
8 changes: 4 additions & 4 deletions codegen/go-composite-schema/main.go
Expand Up @@ -140,20 +140,20 @@ func generateFunctions(ymlFile, goType, schemaProperty string, req bool) string
log.Fatalf("ERROR: Problem reading from file '%v' - %s", ymlFile, err)
}
// json is valid YAML, so we can safely convert, even if it is already json
rawJson, err := yaml.YAMLToJSON(data)
rawJSON, err := yaml.YAMLToJSON(data)
if err != nil {
log.Fatalf("ERROR: Problem converting file '%v' to json format - %s", ymlFile, err)
}
rawJson, err = jsontest.FormatJson(rawJson)
rawJSON, err = jsontest.FormatJson(rawJSON)
if err != nil {
log.Fatalf("ERROR: Problem pretty printing json in '%v' - %s", ymlFile, err)
}
result := "var " + goType + "Schema = func() runtime.CompositeSchema {\n"
result += "\tschema, err := runtime.NewCompositeSchema(\n"
result += "\t\t\"" + schemaProperty + "\",\n"
result += "\t\t`\n"
// the following strings.Replace function call safely escapes backticks (`) in rawJson
result += strings.Replace(text.Indent(fmt.Sprintf("%v", string(rawJson)), "\t\t")+"\n", "`", "` + \"`\" + `", -1)
// the following strings.Replace function call safely escapes backticks (`) in rawJSON
result += strings.Replace(text.Indent(fmt.Sprintf("%v", string(rawJSON)), "\t\t")+"\n", "`", "` + \"`\" + `", -1)
result += "\t\t`,\n"
result += fmt.Sprintf("\t\t%t,\n", req)
result += "\t\tfunc() interface{} {\n"
Expand Down
2 changes: 1 addition & 1 deletion engines/doc.go
@@ -1,4 +1,4 @@
// Package engine specfies the interfaces that each engine must implement.
// Package engines specfies the interfaces that each engine must implement.
//
// This is all rooted at the EngineProvider interface specified in the extpoints
// package, where implementors should register their engine.
Expand Down
2 changes: 1 addition & 1 deletion engines/docker/docker.go
@@ -1,4 +1,4 @@
//go:generate go-composite-schema --unexported --required config config-schema.yml generated_configschema.go

// comments
// Package docker is the engine for executing tasks within a docker environment.
package docker
15 changes: 7 additions & 8 deletions engines/enginetest/artifacts.go
Expand Up @@ -14,8 +14,7 @@ import (
// The ArtifactTestCase contains information sufficient to test artifact
// extration from an engine.
type ArtifactTestCase struct {
engineProvider
Engine string
EngineProvider
// Text to search for in files
Text string
// Path of a file containing the Text string above
Expand All @@ -35,7 +34,7 @@ type ArtifactTestCase struct {

// TestExtractTextFile checks that TextFilePath contains Text
func (c *ArtifactTestCase) TestExtractTextFile() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
assert(r.buildRunSandbox(), "Task failed to run, payload: ", c.Payload)
Expand All @@ -52,7 +51,7 @@ func (c *ArtifactTestCase) TestExtractTextFile() {
// TestExtractFileNotFound checks that FileNotFoundPath returns
// ErrResourceNotFound
func (c *ArtifactTestCase) TestExtractFileNotFound() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
assert(r.buildRunSandbox(), "Task failed to run, payload: ", c.Payload)
Expand All @@ -65,7 +64,7 @@ func (c *ArtifactTestCase) TestExtractFileNotFound() {
// TestExtractFolderNotFound checks that FolderNotFoundPath returns
// ErrResourceNotFound
func (c *ArtifactTestCase) TestExtractFolderNotFound() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
assert(r.buildRunSandbox(), "Task failed to run, payload: ", c.Payload)
Expand All @@ -82,7 +81,7 @@ func (c *ArtifactTestCase) TestExtractFolderNotFound() {
// TestExtractNestedFolderPath checks FolderNotFoundPath contains files
// NestedFolderFiles
func (c *ArtifactTestCase) TestExtractNestedFolderPath() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
assert(r.buildRunSandbox(), "Task failed to run, payload: ", c.Payload)
Expand Down Expand Up @@ -132,7 +131,7 @@ func (c *ArtifactTestCase) TestExtractNestedFolderPath() {
// TestExtractFolderHandlerInterrupt checks that errors in handler given to
// ExtractFolder causes ErrHandlerInterrupt
func (c *ArtifactTestCase) TestExtractFolderHandlerInterrupt() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
assert(r.buildRunSandbox(), "Task failed to run, payload: ", c.Payload)
Expand All @@ -148,7 +147,7 @@ func (c *ArtifactTestCase) TestExtractFolderHandlerInterrupt() {

// Test runs all test cases in parallel
func (c *ArtifactTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(5)
go func() { c.TestExtractTextFile(); wg.Done() }()
Expand Down
12 changes: 5 additions & 7 deletions engines/enginetest/attachproxy.go
Expand Up @@ -10,9 +10,7 @@ import (
// A ProxyTestCase holds information necessary to run tests that an engine
// can attach proxies, call them and forward calls correctly
type ProxyTestCase struct {
engineProvider
// Name of engine
Engine string
EngineProvider
// A valid name for a proxy attachment
ProxyName string
// A task.payload as accepted by the engine, which will write "Pinging"
Expand All @@ -25,7 +23,7 @@ type ProxyTestCase struct {

// TestPingProxyPayload checks that PingProxyPayload works as defined
func (c *ProxyTestCase) TestPingProxyPayload() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.PingProxyPayload)

Expand Down Expand Up @@ -58,7 +56,7 @@ func (c *ProxyTestCase) TestPingProxyPayload() {

// TestPing404IsUnsuccessful checks that 404 returns unsuccessful
func (c *ProxyTestCase) TestPing404IsUnsuccessful() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.PingProxyPayload)

Expand Down Expand Up @@ -88,7 +86,7 @@ func (c *ProxyTestCase) TestPing404IsUnsuccessful() {
// TestLiveLogging checks that "Pinging" is readable from log before the task
// is finished.
func (c *ProxyTestCase) TestLiveLogging() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.PingProxyPayload)

Expand Down Expand Up @@ -145,7 +143,7 @@ func (c *ProxyTestCase) TestParallelPings() {

// Test runs all tests for the ProxyTestCase is parallel
func (c *ProxyTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(4)
go func() { c.TestPingProxyPayload(); wg.Done() }()
Expand Down
16 changes: 7 additions & 9 deletions engines/enginetest/attachvolume.go
Expand Up @@ -11,9 +11,7 @@ import (
// A VolumeTestCase holds information necessary to run tests that an engine
// can create volumes, mount and read/write to volumes.
type VolumeTestCase struct {
engineProvider
// Name of engine
Engine string
EngineProvider
// A valid mountpoint
Mountpoint string
// A task.payload as accepted by the engine, which will write something to the
Expand Down Expand Up @@ -42,7 +40,7 @@ func (c *VolumeTestCase) writeVolume(volume engines.Volume, readOnly bool) bool

// Construct SandboxBuilder, Attach volume to sandbox and run it
func (c *VolumeTestCase) readVolume(volume engines.Volume, readOnly bool) bool {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.CheckVolumePayload)
err := r.sandboxBuilder.AttachVolume(c.Mountpoint, volume, readOnly)
Expand All @@ -52,7 +50,7 @@ func (c *VolumeTestCase) readVolume(volume engines.Volume, readOnly bool) bool {

// TestWriteReadVolume tests that we can write and read from a volume
func (c *VolumeTestCase) TestWriteReadVolume() {
c.ensureEngine(c.Engine)
c.ensureEngine()
volume, err := c.engine.NewCacheFolder()
nilOrPanic(err, "Failed to create a new cache folder")
defer evalNilOrPanic(volume.Dispose, "Failed to dispose cache folder")
Expand All @@ -67,7 +65,7 @@ func (c *VolumeTestCase) TestWriteReadVolume() {

// TestReadEmptyVolume tests that read from empty volume doesn't work
func (c *VolumeTestCase) TestReadEmptyVolume() {
c.ensureEngine(c.Engine)
c.ensureEngine()
volume, err := c.engine.NewCacheFolder()
nilOrPanic(err, "Failed to create a new cache folder")
defer evalNilOrPanic(volume.Dispose, "Failed to dispose cache folder")
Expand All @@ -79,7 +77,7 @@ func (c *VolumeTestCase) TestReadEmptyVolume() {

// TestWriteToReadOnlyVolume tests that write doesn't work to a read-only volume
func (c *VolumeTestCase) TestWriteToReadOnlyVolume() {
c.ensureEngine(c.Engine)
c.ensureEngine()
volume, err := c.engine.NewCacheFolder()
nilOrPanic(err, "Failed to create a new cache folder")
defer evalNilOrPanic(volume.Dispose, "Failed to dispose cache folder")
Expand All @@ -91,7 +89,7 @@ func (c *VolumeTestCase) TestWriteToReadOnlyVolume() {

// TestReadToReadOnlyVolume tests that we can read from a read-only volume
func (c *VolumeTestCase) TestReadToReadOnlyVolume() {
c.ensureEngine(c.Engine)
c.ensureEngine()
volume, err := c.engine.NewCacheFolder()
nilOrPanic(err, "Failed to create a new cache folder")
defer evalNilOrPanic(volume.Dispose, "Failed to dispose cache folder")
Expand All @@ -107,7 +105,7 @@ func (c *VolumeTestCase) TestReadToReadOnlyVolume() {

// Test runs all tests on the test case.
func (c *VolumeTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(4)
go func() { c.TestWriteReadVolume(); wg.Done() }()
Expand Down
2 changes: 1 addition & 1 deletion engines/enginetest/display.go
Expand Up @@ -5,7 +5,7 @@ import "github.com/taskcluster/taskcluster-worker/engines"
// The DisplayTestCase contains information sufficient to test the interactive
// display provided by a Sandbox
type DisplayTestCase struct {
Engine string
EngineProvider
// List of display that should be returned from Sandbox.ListDisplays(),
// They will all be opened to ensure that they are in fact VNC connections.
Displays []engines.Display
Expand Down
12 changes: 5 additions & 7 deletions engines/enginetest/environmentvariable.go
Expand Up @@ -9,9 +9,7 @@ import (
// The EnvVarTestCase contains information sufficient to setting an environment
// variable.
type EnvVarTestCase struct {
engineProvider
// Name of engine
Engine string
EngineProvider
// Valid name for an environment variable.
VariableName string
// Invalid environment variable names.
Expand All @@ -22,7 +20,7 @@ type EnvVarTestCase struct {

// TestPrintVariable checks that variable value can be printed
func (c *EnvVarTestCase) TestPrintVariable() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
err := r.sandboxBuilder.SetEnvironmentVariable(c.VariableName, "Hello World")
Expand All @@ -33,7 +31,7 @@ func (c *EnvVarTestCase) TestPrintVariable() {

// TestVariableNameConflict checks that variable name can't conflict
func (c *EnvVarTestCase) TestVariableNameConflict() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
err := r.sandboxBuilder.SetEnvironmentVariable(c.VariableName, "Hello World")
Expand All @@ -46,7 +44,7 @@ func (c *EnvVarTestCase) TestVariableNameConflict() {

// TestInvalidVariableNames checks that invalid variables returns correct error
func (c *EnvVarTestCase) TestInvalidVariableNames() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
for _, name := range c.InvalidVariableNames {
Expand All @@ -59,7 +57,7 @@ func (c *EnvVarTestCase) TestInvalidVariableNames() {

// Test runs all tests in parallel
func (c *EnvVarTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(3)
go func() { c.TestPrintVariable(); wg.Done() }()
Expand Down
8 changes: 3 additions & 5 deletions engines/enginetest/logging.go
Expand Up @@ -5,9 +5,7 @@ import "sync"
// A LoggingTestCase holds information necessary to run tests that an engine
// can write things to the log.
type LoggingTestCase struct {
engineProvider
// Name of engine
Engine string
EngineProvider
// String that we will look for in the log
Target string
// A task.payload as accepted by the engine, which will Target to the log and
Expand All @@ -20,7 +18,7 @@ type LoggingTestCase struct {
}

func (c *LoggingTestCase) grepLogFromPayload(payload string, needle string, success bool) bool {
r := c.NewRun(c.Engine)
r := c.newRun()
r.NewSandboxBuilder(payload)
s := r.buildRunSandbox()
if s != success {
Expand Down Expand Up @@ -52,7 +50,7 @@ func (c *LoggingTestCase) TestSilentTask() {

// Test will run all logging tests
func (c *LoggingTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(3)
go func() { c.TestLogTarget(); wg.Done() }()
Expand Down
11 changes: 5 additions & 6 deletions engines/enginetest/shell.go
Expand Up @@ -11,8 +11,7 @@ import (
// The ShellTestCase contains information sufficient to test the interactive
// shell provided by a Sandbox
type ShellTestCase struct {
engineProvider
Engine string
EngineProvider
// Command to pipe to the Shell over stdin
Command string
// Result to expect from the Shell on stdout when running Command
Expand All @@ -30,7 +29,7 @@ type ShellTestCase struct {

// TestCommand checks we can run Command in the shell
func (c *ShellTestCase) TestCommand() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
r.StartSandbox()
Expand Down Expand Up @@ -72,7 +71,7 @@ func (c *ShellTestCase) TestCommand() {

// TestBadCommand checks we can run BadCommand in the shell
func (c *ShellTestCase) TestBadCommand() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
r.StartSandbox()
Expand Down Expand Up @@ -107,7 +106,7 @@ func (c *ShellTestCase) TestBadCommand() {

// TestAbortSleepCommand checks we can Abort the sleep command
func (c *ShellTestCase) TestAbortSleepCommand() {
r := c.NewRun(c.Engine)
r := c.newRun()
defer r.Dispose()
r.NewSandboxBuilder(c.Payload)
r.StartSandbox()
Expand Down Expand Up @@ -146,7 +145,7 @@ func (c *ShellTestCase) TestAbortSleepCommand() {

// Test runs all tests in parallel
func (c *ShellTestCase) Test() {
c.ensureEngine(c.Engine)
c.ensureEngine()
wg := sync.WaitGroup{}
wg.Add(3)
go func() { c.TestCommand(); wg.Done() }()
Expand Down

0 comments on commit 64f7bf3

Please sign in to comment.