예제 #1
0
파일: libvert_test.go 프로젝트: kapilt/juju
func (s *LibVertSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	// Skip if not linux
	if runtime.GOOS != "linux" {
		c.Skip("not running linux")
	}
}
예제 #2
0
파일: client_test.go 프로젝트: zhouqt/juju
func (s *keymanagerSuite) TestImportKeysInvalidUser(c *gc.C) {
	c.Skip("no user validation done yet")
	s.assertInvalidUserOperation(c, func(user string, keys []string) error {
		_, err := s.keymanager.ImportKeys(user, keys...)
		return err
	})
}
예제 #3
0
파일: ec2i_test.go 프로젝트: hailocab/goamz
func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) {
	if !testutil.Amazon {
		c.Skip("AmazonClientSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.ec2 = ec2.New(s.srv.auth, aws.USEast)
}
예제 #4
0
func (s *keyManagerSuite) TestDeleteKeysInvalidUser(c *gc.C) {
	c.Skip("no user validation done yet")
	s.assertInvalidUserOperation(c, func(args params.ModifyUserSSHKeys) error {
		_, err := s.keymanager.DeleteKeys(args)
		return err
	})
}
예제 #5
0
func (s *IntegrationTestSuite) TestSimpleInstallWithEnv(c *chk.C) {
	if !*hasEnvFile {
		c.Skip("-env-file not specified")
	}

	id, err := containers.NewIdentifier("IntTest008")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", EnvImage, hostContainerId, "--env-file=deployment/fixtures/simple.env", "--start")
	data, err := cmd.CombinedOutput()
	c.Log(cmd.Args)
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	time.Sleep(time.Second * 5) // startup time is indeterminate unfortunately because gear init --post continues to run

	cmd = exec.Command("/usr/bin/gear", "status", hostContainerId)
	data, err = cmd.CombinedOutput()
	c.Assert(err, chk.IsNil)
	c.Log(string(data))
	c.Assert(strings.Contains(string(data), "TEST=\"value\""), chk.Equals, true)
	c.Assert(strings.Contains(string(data), "QUOTED=\"foo\""), chk.Equals, true)
}
예제 #6
0
func (*testWrapper) TestKeyError(c *C.C) {
	cwd, err := os.Getwd()
	if err != nil {
		c.Skip(err.Error())
	}

	var errs sectionErrors
	data := make(connectionData)
	addSettingSection(data, section8021x)

	// check 8021x cert file
	errs = make(sectionErrors)
	logicSetSettingVk8021xCaCert(data, cwd+"/testdata/ca.crt")
	checkSetting8021xCaCert(data, errs)
	c.Check(len(errs), C.Equals, 0)

	errs = make(sectionErrors)
	logicSetSettingVk8021xCaCert(data, cwd+"/testdata/ca.crt.notexists")
	checkSetting8021xCaCert(data, errs)
	c.Check(len(errs), C.Equals, 1)

	errs = make(sectionErrors)
	logicSetSettingVk8021xCaCert(data, "abc"+cwd+"/testdata/ca.crt")
	checkSetting8021xCaCert(data, errs)
	c.Check(len(errs), C.Equals, 1)
}
예제 #7
0
func (s *IntegrationTestSuite) TestSimpleInstallWithEnv(c *chk.C) {
	if !*hasEnvFile {
		c.Skip("-env-file not specified")
	}

	id, err := containers.NewIdentifier("IntTest008")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", EnvImage, hostContainerId, "--env-file=deployment/fixtures/simple.env", "--start")
	data, err := cmd.CombinedOutput()
	c.Log(cmd.Args)
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerStarts(c, id)

	cmd = exec.Command("/usr/bin/gear", "status", hostContainerId)
	data, err = cmd.CombinedOutput()

	c.Assert(err, chk.IsNil)
	c.Log(string(data))
	c.Assert(strings.Contains(string(data), "TEST=\"value\""), chk.Equals, true)
	c.Assert(strings.Contains(string(data), "QUOTED=\"\\\"foo\\\"\""), chk.Equals, true)
	c.Assert(strings.Contains(string(data), "IGNORED"), chk.Equals, false)

	cmd = exec.Command("/usr/bin/gear", "stop", hostContainerId)
	data, err = cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerStops(c, id, true)
}
예제 #8
0
// Tests
func (s *S) TestHash(c *check.C) {
	var (
		err     error
		f       *os.File
		md5hash []byte
	)

	// FIXME: This will not work with MacOS.
	if _, err = exec.LookPath("md5sum"); err != nil {
		c.Skip(err.Error())
	}
	md5sum := exec.Command("md5sum", "./files_test.go")
	b := &bytes.Buffer{}
	md5sum.Stdout = b
	if err = md5sum.Run(); err != nil {
		c.Fatal(err)
	}
	if f, err = os.Open("./files_test.go"); err != nil {
		c.Fatalf("%v %s", md5sum, err)
	}
	if md5hash, err = Hash(md5.New(), f); err != nil {
		c.Fatal(err)
	}
	md5string := fmt.Sprintf("%x .*\n", md5hash)

	c.Check(string(b.Bytes()), check.Matches, md5string)
}
예제 #9
0
func (s *SSHGoCryptoCommandSuite) TestProxyCommand(c *gc.C) {
	realNetcat, err := exec.LookPath("nc")
	if err != nil {
		c.Skip("skipping test, couldn't find netcat: %v")
		return
	}
	netcat := filepath.Join(c.MkDir(), "nc")
	err = ioutil.WriteFile(netcat, []byte("#!/bin/sh\necho $0 \"$@\" > $0.args && exec "+realNetcat+" \"$@\""), 0755)
	c.Assert(err, gc.IsNil)

	private, _, err := ssh.GenerateKey("test-server")
	c.Assert(err, gc.IsNil)
	key, err := cryptossh.ParsePrivateKey([]byte(private))
	client, err := ssh.NewGoCryptoClient(key)
	c.Assert(err, gc.IsNil)
	server := newServer(c)
	var opts ssh.Options
	port := server.listener.Addr().(*net.TCPAddr).Port
	opts.SetProxyCommand(netcat, "-q0", "%h", "%p")
	opts.SetPort(port)
	cmd := client.Command("127.0.0.1", testCommand, &opts)
	server.cfg.PublicKeyCallback = func(_ cryptossh.ConnMetadata, pubkey cryptossh.PublicKey) (*cryptossh.Permissions, error) {
		return nil, nil
	}
	go server.run(c)
	out, err := cmd.Output()
	c.Assert(err, gc.IsNil)
	c.Assert(string(out), gc.Equals, "abc value\n")
	// Ensure the proxy command was executed with the appropriate arguments.
	data, err := ioutil.ReadFile(netcat + ".args")
	c.Assert(err, gc.IsNil)
	c.Assert(string(data), gc.Equals, fmt.Sprintf("%s -q0 127.0.0.1 %v\n", netcat, port))
}
예제 #10
0
파일: livetests.go 프로젝트: jkary/core
func (t *LiveTests) TestCheckEnvironmentOnConnectBadVerificationFile(c *gc.C) {
	// When new connection is established to a bootstraped environment,
	// it is checked that we are running against a juju-core environment.
	//
	// If the verification file has unexpected content, it is not
	// a juju-core environment (likely to a Python juju environment).
	if !t.CanOpenState {
		c.Skip("CanOpenState is false; cannot open state connection")
	}
	t.BootstrapOnce(c)
	environ := t.Env
	stor := environ.Storage()

	// Finally, replace the content with an arbitrary string.
	badVerificationContent := "bootstrap storage verification"
	reader := strings.NewReader(badVerificationContent)
	err := stor.Put(
		"bootstrap-verify",
		reader,
		int64(len(badVerificationContent)))
	c.Assert(err, gc.IsNil)
	defer restoreBootstrapVerificationFile(c, stor)

	// Running NewConn() should fail.
	_, err = juju.NewConn(t.Env)
	c.Assert(err, gc.Equals, environs.InvalidEnvironmentError)
}
예제 #11
0
func (s *AmazonServerSuite) SetUpSuite(c *gocheck.C) {
	if !*amazon {
		c.Skip("AmazonServerSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.ServerTests.elb = elb.New(s.srv.auth, aws.USEast)
}
예제 #12
0
파일: server_test.go 프로젝트: jkary/core
func (s *StoreSuite) TestStatsCounter(c *gc.C) {
	if *noTestMongoJs {
		c.Skip("MongoDB javascript not available")
	}

	for _, key := range [][]string{{"a", "b"}, {"a", "b"}, {"a", "c"}, {"a"}} {
		err := s.store.IncCounter(key)
		c.Assert(err, gc.IsNil)
	}

	server, _ := s.prepareServer(c)

	expected := map[string]string{
		"a:b":   "2",
		"a:b:*": "0",
		"a:*":   "3",
		"a":     "1",
		"a:b:c": "0",
	}

	for counter, n := range expected {
		req, err := http.NewRequest("GET", "/stats/counter/"+counter, nil)
		c.Assert(err, gc.IsNil)
		rec := httptest.NewRecorder()
		server.ServeHTTP(rec, req)

		data, err := ioutil.ReadAll(rec.Body)
		c.Assert(string(data), gc.Equals, n)

		c.Assert(rec.Header().Get("Content-Type"), gc.Equals, "text/plain")
		c.Assert(rec.Header().Get("Content-Length"), gc.Equals, strconv.Itoa(len(n)))
	}
}
예제 #13
0
func (s *SSHGoCryptoCommandSuite) TestProxyCommand(c *gc.C) {
	realNetcat, err := exec.LookPath("nc")
	if err != nil {
		c.Skip("skipping test, couldn't find netcat: %v")
		return
	}
	netcat := filepath.Join(c.MkDir(), "nc")
	err = ioutil.WriteFile(netcat, []byte("#!/bin/sh\necho $0 \"$@\" > $0.args && exec "+realNetcat+" \"$@\""), 0755)
	c.Assert(err, gc.IsNil)

	private, _, err := ssh.GenerateKey("test-server")
	c.Assert(err, gc.IsNil)
	key, err := cryptossh.ParsePrivateKey([]byte(private))
	client, err := ssh.NewGoCryptoClient(key)
	c.Assert(err, gc.IsNil)
	server := newServer(c)
	var opts ssh.Options
	port := server.Addr().(*net.TCPAddr).Port
	opts.SetProxyCommand(netcat, "-q0", "%h", "%p")
	opts.SetPort(port)
	cmd := client.Command("127.0.0.1", testCommand, &opts)
	server.cfg.PublicKeyCallback = func(conn *cryptossh.ServerConn, user, algo string, pubkey []byte) bool {
		return true
	}
	go server.run(c)
	out, err := cmd.Output()
	c.Assert(err, gc.ErrorMatches, "ssh: could not execute command.*")
	// TODO(axw) when gosshnew is ready, expect reply from server.
	c.Assert(out, gc.IsNil)
	// Ensure the proxy command was executed with the appropriate arguments.
	data, err := ioutil.ReadFile(netcat + ".args")
	c.Assert(err, gc.IsNil)
	c.Assert(string(data), gc.Equals, fmt.Sprintf("%s -q0 127.0.0.1 %v\n", netcat, port))
}
예제 #14
0
파일: client_test.go 프로젝트: zhouqt/juju
func (s *keymanagerSuite) TestListKeysErrors(c *gc.C) {
	c.Skip("the user name isn't checked for existence yet")
	keyResults, err := s.keymanager.ListKeys(ssh.Fingerprints, "invalid")
	c.Assert(err, gc.IsNil)
	c.Assert(len(keyResults), gc.Equals, 1)
	result := keyResults[0]
	c.Assert(result.Error, gc.ErrorMatches, `permission denied`)
}
예제 #15
0
파일: livetests.go 프로젝트: klyachin/juju
func (t *LiveTests) TestBootstrapWithDefaultSeries(c *gc.C) {
	if !t.HasProvisioner {
		c.Skip("HasProvisioner is false; cannot test deployment")
	}

	current := version.Current
	other := current
	other.Series = "quantal"
	if current == other {
		other.Series = "precise"
	}

	dummyCfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(coretesting.Attrs{
		"state-server": false,
		"name":         "dummy storage",
	}))
	dummyenv, err := environs.Prepare(dummyCfg, coretesting.Context(c), configstore.NewMem())
	c.Assert(err, gc.IsNil)
	defer dummyenv.Destroy()

	t.Destroy(c)

	attrs := t.TestConfig.Merge(coretesting.Attrs{"default-series": other.Series})
	cfg, err := config.New(config.NoDefaults, attrs)
	c.Assert(err, gc.IsNil)
	env, err := environs.Prepare(cfg, coretesting.Context(c), t.ConfigStore)
	c.Assert(err, gc.IsNil)
	defer environs.Destroy(env, t.ConfigStore)

	currentName := envtools.StorageName(current)
	otherName := envtools.StorageName(other)
	envStorage := env.Storage()
	dummyStorage := dummyenv.Storage()

	defer envStorage.Remove(otherName)

	_, err = sync.Upload(dummyStorage, &current.Number)
	c.Assert(err, gc.IsNil)

	// This will only work while cross-compiling across releases is safe,
	// which depends on external elements. Tends to be safe for the last
	// few releases, but we may have to refactor some day.
	err = storageCopy(dummyStorage, currentName, envStorage, otherName)
	c.Assert(err, gc.IsNil)

	err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
	c.Assert(err, gc.IsNil)

	st := t.Env.(testing.GetStater).GetStateInAPIServer()
	// Wait for machine agent to come up on the bootstrap
	// machine and ensure it deployed the proper series.
	m0, err := st.Machine("0")
	c.Assert(err, gc.IsNil)
	mw0 := newMachineToolWaiter(m0)
	defer mw0.Stop()

	waitAgentTools(c, mw0, other)
}
예제 #16
0
func (s *StoreSuite) TestCountersTokenCaching(c *gc.C) {
	if *noTestMongoJs {
		c.Skip("MongoDB javascript not available")
	}

	assertSum := func(i int, want int64) {
		req := charmstore.CounterRequest{Key: []string{strconv.Itoa(i)}}
		cs, err := s.store.Counters(&req)
		c.Assert(err, gc.IsNil)
		c.Assert(cs[0].Count, gc.Equals, want)
	}
	assertSum(100000, 0)

	const genSize = 1024

	// All of these will be cached, as we have two generations
	// of genSize entries each.
	for i := 0; i < genSize*2; i++ {
		err := s.store.IncCounter([]string{strconv.Itoa(i)})
		c.Assert(err, gc.IsNil)
	}

	// Now go behind the scenes and corrupt all the tokens.
	tokens := s.Session.DB("juju").C("stat.tokens")
	iter := tokens.Find(nil).Iter()
	var t struct {
		Id    int    "_id"
		Token string "t"
	}
	for iter.Next(&t) {
		err := tokens.UpdateId(t.Id, bson.M{"$set": bson.M{"t": "corrupted" + t.Token}})
		c.Assert(err, gc.IsNil)
	}
	c.Assert(iter.Err(), gc.IsNil)

	// We can consult the counters for the cached entries still.
	// First, check that the newest generation is good.
	for i := genSize; i < genSize*2; i++ {
		assertSum(i, 1)
	}

	// Now, we can still access a single entry of the older generation,
	// but this will cause the generations to flip and thus the rest
	// of the old generation will go away as the top half of the
	// entries is turned into the old generation.
	assertSum(0, 1)

	// Now we've lost access to the rest of the old generation.
	for i := 1; i < genSize; i++ {
		assertSum(i, 0)
	}

	// But we still have all of the top half available since it was
	// moved into the old generation.
	for i := genSize; i < genSize*2; i++ {
		assertSum(i, 1)
	}
}
예제 #17
0
파일: s3i_test.go 프로젝트: hailocab/goamz
func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) {
	if !testutil.Amazon {
		c.Skip("live tests against AWS disabled (no -amazon)")
	}
	s.srv.SetUp(c)
	s.s3 = s3.New(s.srv.auth, s.Region)
	// In case tests were interrupted in the middle before.
	s.ClientTests.Cleanup()
}
예제 #18
0
func (s *InterpreterSuite) TestInterpreterSqrtRecursive(c *gc.C) {
	c.Skip("TODO: builtinDivide() use of BigRat appears going wrong")
	result, err := Interpret(squareRootSicp)
	if err != nil {
		c.Errorf("Interpret() failed: %v", err)
	} else {
		c.Check(result, gc.Equals, NewInteger(12345))
	}
}
예제 #19
0
파일: s3i_test.go 프로젝트: hailocab/goamz
func (s *AmazonDomainClientSuite) SetUpSuite(c *gocheck.C) {
	if !testutil.Amazon {
		c.Skip("live tests against AWS disabled (no -amazon)")
	}
	s.srv.SetUp(c)
	region := s.Region
	region.S3BucketEndpoint = "https://${bucket}.s3.amazonaws.com"
	s.s3 = s3.New(s.srv.auth, region)
	s.ClientTests.Cleanup()
}
예제 #20
0
파일: suite.go 프로젝트: kixelated/goamz
func (s *LiveSuite) SetUpSuite(c *gocheck.C) {
	if !Amazon {
		c.Skip("amazon tests not enabled (-amazon flag)")
	}
	auth, err := aws.EnvAuth()
	if err != nil {
		c.Fatal(err.Error())
	}
	s.auth = auth
}
예제 #21
0
파일: suite_test.go 프로젝트: pmn/goamz
func (s *SuiteI) SetUpSuite(c *gocheck.C) {
	if !*integration {
		c.Skip("Integration tests not enabled (-int flag)")
	}
	auth, err := aws.EnvAuth()
	if err != nil {
		c.Fatal(err)
	}
	s.auth = auth
}
예제 #22
0
func (s *ItemManagerTestSuite) addTestItem(c *C.C, path string) ItemInfoInterface {
	desktop := gio.NewDesktopAppInfoFromFilename(path)
	if desktop == nil {
		c.Skip(createDesktopFailed(path))
	}
	item := NewItem(desktop)
	s.m.AddItem(item)
	desktop.Unref()
	return item
}
예제 #23
0
func (s *FixtureHelper) trace(name string, c *gocheck.C) {
	n := s.n
	s.calls[n] = name
	s.n += 1
	if name == s.panicOn {
		panic(name)
	}
	if s.skip && s.skipOnN == n {
		c.Skip("skipOnN == n")
	}
}
예제 #24
0
func (s *configRootSuite) SetUpTest(c *gc.C) {
	s.baseProviderSuite.SetUpTest(c)
	// Skip if not linux
	if runtime.GOOS != "linux" {
		c.Skip("not running linux")
	}
	// Skip if not running as root.
	if os.Getuid() != 0 {
		c.Skip("not running as root")
	}
}
예제 #25
0
// TODO(jam): 2013-09-02 http://pad.lv/1219661
// This test has been failing regularly on the Bot. Until someone fixes it so
// it doesn't crash, it isn't worth having as we can't tell when someone
// actually breaks something.
func (s *MachineSuite) TestManageEnvironServesAPI(c *gc.C) {
	c.Skip("does not pass reliably on the bot (http://pad.lv/1219661")
	s.assertJobWithState(c, state.JobManageEnviron, func(conf agent.Config, agentState *state.State) {
		st, err := api.Open(conf.APIInfo(), fastDialOpts)
		c.Assert(err, gc.IsNil)
		defer st.Close()
		m, err := st.Machiner().Machine(conf.Tag())
		c.Assert(err, gc.IsNil)
		c.Assert(m.Life(), gc.Equals, params.Alive)
	})
}
예제 #26
0
파일: bundle_test.go 프로젝트: bz2/charm
func (s *BundleSuite) TestManifestSymlink(c *gc.C) {
	srcPath := charmtesting.Charms.ClonedDirPath(c.MkDir(), "dummy")
	if err := os.Symlink("../target", filepath.Join(srcPath, "hooks/symlink")); err != nil {
		c.Skip("cannot symlink")
	}
	expected := append([]string{"hooks/symlink"}, dummyManifest...)

	bundle := bundleDir(c, srcPath)
	manifest, err := bundle.Manifest()
	c.Assert(err, gc.IsNil)
	c.Assert(manifest, gc.DeepEquals, set.NewStrings(expected...))
}
예제 #27
0
func (vms *VirtMachSuite) TestRecursiveSqrt(c *gc.C) {
	c.Skip("TODO: builtinDivide() use of BigRat appears going wrong")
	name := "TestRecursiveSqrt"
	code, err := CompileString(name, squareRootSicp)
	c.Assert(err, gc.IsNil, gc.Commentf("failed to compile code: %s", err))
	c.Assert(code, gc.NotNil, gc.Commentf("failed to produce code"))
	env := NewEnvironment(theReportEnvironment)
	result, err := EvaluateCode(code, env)
	c.Assert(err, gc.IsNil, gc.Commentf("failed to evaluate code: %s", err))
	c.Assert(result, gc.NotNil, gc.Commentf("lambda failed to yield result"))
	c.Check(result, gc.Equals, NewInteger(12345))
}
예제 #28
0
func (s *FixtureHelper) trace(name string, c *gocheck.C) {
	s.calls = append(s.calls, name)
	if name == s.panicOn {
		panic(name)
	}
	if s.sleep > 0 && s.sleepOn == name {
		time.Sleep(s.sleep)
	}
	if s.skip && s.skipOnN == len(s.calls)-1 {
		c.Skip("skipOnN == n")
	}
}
예제 #29
0
파일: livetests.go 프로젝트: klyachin/juju
func (t *LiveTests) TestCheckEnvironmentOnConnect(c *gc.C) {
	// When new connection is established to a bootstraped environment,
	// it is checked that we are running against a juju-core environment.
	if !t.CanOpenState {
		c.Skip("CanOpenState is false; cannot open state connection")
	}
	t.BootstrapOnce(c)

	apiState, err := juju.NewAPIState(t.Env, api.DefaultDialOpts())
	c.Assert(err, gc.IsNil)
	apiState.Close()
}
예제 #30
0
func (s *TableSuite) SetUpSuite(c *gocheck.C) {
	setUpAuth(c)
	s.DynamoDBTest.TableDescriptionT = s.TableDescriptionT
	s.server = &dynamodb.Server{dynamodb_auth, dynamodb_region}
	pk, err := s.TableDescriptionT.BuildPrimaryKey()
	if err != nil {
		c.Skip(err.Error())
	}
	s.table = s.server.NewTable(s.TableDescriptionT.TableName, pk)

	// Cleanup
	s.TearDownSuite(c)
}