Permalink
Browse files

various fixes for windows tests

  • Loading branch information...
1 parent bb6c733 commit 73b4f331085fabd5bef5188e5af193118ec573fb @gabriel-samfira gabriel-samfira committed Apr 16, 2015
@@ -21,6 +21,7 @@ import (
"github.com/juju/juju/service"
systemdtesting "github.com/juju/juju/service/systemd/testing"
"github.com/juju/juju/testing"
+ "github.com/juju/juju/version"
)
func Test(t *stdtesting.T) {
@@ -184,6 +185,7 @@ end script
}
func (s *UserDataSuite) TestShutdownInitCommandsSystemd(c *gc.C) {
+ s.PatchValue(&version.Current.Series, "vivid")
commands, err := containerinit.ShutdownInitCommands(service.InitSystemSystemd)
c.Assert(err, jc.ErrorIsNil)
View
@@ -119,7 +119,15 @@ func (c *baseConfigure) addMachineAgentToBoot() error {
cmds = append(cmds, startCmds...)
svcName := c.icfg.MachineAgentServiceName
- c.conf.AddRunCmd(cloudinit.LogProgressCmd("Starting Juju machine agent (%s)", svcName))
+ // TODO (gsamfira): This is temporary until we find a cleaner way to fix
+ // cloudinit.LogProgressCmd to not add >&9 on Windows.
+ targetOS, err := version.GetOSFromSeries(c.icfg.Series)
+ if err != nil {
+ return err
+ }
+ if targetOS != version.Windows {
+ c.conf.AddRunCmd(cloudinit.LogProgressCmd("Starting Juju machine agent (%s)", svcName))
+ }
c.conf.AddScripts(cmds...)
return nil
}
@@ -104,8 +104,8 @@ func minimalInstanceConfig(tweakers ...func(instancecfg.InstanceConfig)) instanc
EnvironTag: testing.EnvironmentTag,
},
Constraints: envConstraints,
- DataDir: instancecfg.DataDir,
- LogDir: agent.DefaultLogDir,
+ DataDir: dataDir,
+ LogDir: logDir,
Jobs: allMachineJobs,
CloudInitOutputLog: cloudInitOutputLog,
InstanceId: "i-bootstrap",
@@ -994,8 +994,8 @@ func (*cloudinitSuite) TestCloudInitVerify(c *gc.C) {
EnvironTag: testing.EnvironmentTag,
},
Config: minimalConfig(c),
- DataDir: instancecfg.DataDir,
- LogDir: agent.DefaultLogDir,
+ DataDir: dataDir,
+ LogDir: logDir,
Jobs: normalMachineJobs,
CloudInitOutputLog: cloudInitOutputLog,
InstanceId: "i-bootstrap",
@@ -2,8 +2,6 @@
// Copyright 2014, 2015 Cloudbase Solutions
// Licensed under the AGPLv3, see LICENCE file for details.
-// +build !windows
-
package cloudconfig
import (
@@ -873,7 +873,6 @@ values:
"@
cmd.exe /C mklink /D C:\Juju\lib\juju\tools\machine-10 1.2.3-win8-amd64
-echo 'Starting Juju machine agent (jujud-machine-10)' >&9
New-Service -Credential $jujuCreds -Name 'jujud-machine-10' -DisplayName 'juju agent for machine-10' '''C:\Juju\lib\juju\tools\machine-10\jujud.exe'' machine --data-dir ''C:\Juju\lib\juju'' --machine-id 10 --debug'
cmd.exe /C sc config 'jujud-machine-10' start=delayed-auto
Start-Service 'jujud-machine-10'`
@@ -9,6 +9,7 @@ import (
"github.com/juju/cmd"
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
+ "github.com/juju/utils"
gc "gopkg.in/check.v1"
"gopkg.in/yaml.v1"
@@ -164,7 +165,8 @@ func (s *createSuite) TestConfigFileFormatError(c *gc.C) {
func (s *createSuite) TestConfigFileDoesntExist(c *gc.C) {
_, err := s.run(c, "test", "--config", "missing-file")
- c.Assert(err, gc.ErrorMatches, `open .* no such file or directory`)
+ errMsg := ".*" + utils.NoSuchFileErrRegexp
+ c.Assert(err, gc.ErrorMatches, errMsg)
}
func (s *createSuite) TestConfigValuePrecedence(c *gc.C) {
@@ -6,6 +6,7 @@ package local_test
import (
"fmt"
"os/exec"
+ "runtime"
"strings"
"github.com/juju/cmd"
@@ -60,6 +61,9 @@ func (s *mainSuite) TestRunAsRootCallsFuncIfRoot(c *gc.C) {
}
func (s *mainSuite) TestRunAsRootCallsSudoIfNotRoot(c *gc.C) {
+ if runtime.GOOS == "windows" {
+ c.Skip("No root on windows")
+ }
s.PatchValue(local.CheckIfRoot, func() bool { return false })
testing.PatchExecutableAsEchoArgs(c, s, "sudo")
// the command needs to be in the path...
View
@@ -37,7 +37,7 @@ google.golang.org/cloud git f20d6dcccb44ed49de45ae3703312cb46e627db1 2015-03-19T
gopkg.in/amz.v3 git f5c958d2b012da23a4600bad441f20b13ec262c4 2015-04-03T18:23:57Z
gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z
gopkg.in/errgo.v1 git 81357a83344ddd9f7772884874e5622c2a3da21c 2014-10-13T17:33:38Z
-gopkg.in/juju/charm.v5 git 4ce6225dae243c82f8a342749accaefbadad38e0 2015-04-10T08:52:37Z
+gopkg.in/juju/charm.v5 git 6b74a2771545912f8a91a544b0f28405b9938624 2015-04-14T14:33:47Z
gopkg.in/juju/charmstore.v4 git ab64d50370f9c167a7cd55be8ea22c3842aae46d 2015-04-10T09:44:12Z
gopkg.in/macaroon-bakery.v0 git 9593b80b01ba04b519769d045dffd6abd827d2fd 2015-04-10T07:46:55Z
gopkg.in/macaroon.v1 git ab3940c6c16510a850e1c2dd628b919f0f3f1464 2015-01-21T11:42:31Z
@@ -11,7 +11,6 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- "github.com/juju/juju/agent"
"github.com/juju/juju/api"
"github.com/juju/juju/cloudconfig/instancecfg"
"github.com/juju/juju/cloudconfig/providerinit"
@@ -37,6 +36,7 @@ func must(s string, err error) string {
}
var logDir = must(paths.LogDir("precise"))
+var dataDir = must(paths.DataDir("precise"))
var cloudInitOutputLog = path.Join(logDir, "cloud-init-output.log")
// makeInstanceConfig produces a valid cloudinit machine config.
@@ -46,8 +46,8 @@ func makeInstanceConfig(c *gc.C) *instancecfg.InstanceConfig {
return &instancecfg.InstanceConfig{
MachineId: machineId,
MachineNonce: "gxshasqlnng",
- DataDir: instancecfg.DataDir,
- LogDir: agent.DefaultLogDir,
+ DataDir: dataDir,
+ LogDir: logDir,
Jobs: []multiwatcher.MachineJob{
multiwatcher.JobManageEnviron,
multiwatcher.JobHostUnits,
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"os/exec"
+ "runtime"
"path"
"regexp"
"text/template"
@@ -31,6 +32,12 @@ var (
// IsRunning returns whether or not upstart is the local init system.
func IsRunning() (bool, error) {
+ // On windows casting the error to exec.Error does not yield a os.PathError type
+ // Its easyer to just return nil before even trying to execute an external command
+ // on windows at least
+ if runtime.GOOS == "windows" {
+ return false, nil
+ }
cmd := exec.Command(initctlPath, "--system", "list")
_, err := cmd.CombinedOutput()
if err == nil {
View
@@ -107,6 +107,13 @@ func (s *Service) Status() (string, error) {
// Running returns true if the Service appears to be running.
func (s *Service) Running() (bool, error) {
+ installed, err := s.Installed()
+ if err != nil {
+ return false, err
+ }
+ if !installed {
+ return false, nil
+ }
status, err := s.Status()
logger.Infof("Service %q Status %q", s.Service.Name, status)
if err != nil {
@@ -120,11 +127,16 @@ func (s *Service) Running() (bool, error) {
// Installed returns whether the service is installed
func (s *Service) Installed() (bool, error) {
- _, err := s.Status()
+ services, err := ListServices()
if err != nil {
- return false, errors.Trace(err)
+ return false, err
}
- return true, nil
+ for _, val := range services {
+ if val == s.Name() {
+ return true, nil
+ }
+ }
+ return false, nil
}
// Exists returns whether the service configuration exists in the
@@ -168,7 +180,14 @@ func (s *Service) Stop() error {
// Remove deletes the service.
func (s *Service) Remove() error {
- _, err := s.Status()
+ installed, err := s.Installed()
+ if err != nil {
+ return err
+ }
+ if !installed {
+ return nil
+ }
+ err = s.Stop()
if err != nil {
return err
}
@@ -6,6 +6,7 @@ package provider_test
import (
"errors"
"path/filepath"
+ "runtime"
"github.com/juju/names"
jc "github.com/juju/testing/checkers"
@@ -26,6 +27,9 @@ type rootfsSuite struct {
}
func (s *rootfsSuite) SetUpTest(c *gc.C) {
+ if runtime.GOOS == "windows" {
+ c.Skip("Tests relevant only on *nix systems")
+ }
s.BaseSuite.SetUpTest(c)
s.storageDir = c.MkDir()
}
@@ -5,6 +5,7 @@ package provider_test
import (
"errors"
+ "runtime"
"github.com/juju/names"
jc "github.com/juju/testing/checkers"
@@ -24,6 +25,9 @@ type tmpfsSuite struct {
}
func (s *tmpfsSuite) SetUpTest(c *gc.C) {
+ if runtime.GOOS == "windows" {
+ c.Skip("Tests relevant only on *nix systems")
+ }
s.BaseSuite.SetUpTest(c)
s.storageDir = c.MkDir()
}
@@ -403,6 +403,13 @@ type SetIPAndARPForwardingSuite struct {
coretesting.BaseSuite
}
+func (s *SetIPAndARPForwardingSuite) SetUpSuite(c *gc.C) {
+ if runtime.GOOS == "windows" {
+ c.Skip("bug 1403084: Skipping for now")
+ }
+ s.BaseSuite.SetUpSuite(c)
+}
+
var _ = gc.Suite(&SetIPAndARPForwardingSuite{})
func (s *SetIPAndARPForwardingSuite) TestSuccess(c *gc.C) {

0 comments on commit 73b4f33

Please sign in to comment.