本文整理汇总了Golang中github.com/openshift/origin/test/extended/util/db.NewMongoDB函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMongoDB函数的具体用法?Golang NewMongoDB怎么用?Golang NewMongoDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMongoDB函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: readRecordFromPod
func readRecordFromPod(oc *exutil.CLI, podName string) error {
// don't include _id field to output because it changes every time
findCmd := "rs.slaveOk(); printjson(db.test.find({}, {_id: 0}).toArray())"
fmt.Fprintf(g.GinkgoWriter, "DEBUG: reading record from the pod %v\n", podName)
mongoPod := dbutil.NewMongoDB(podName)
// pod is running but we need to wait when it will be really ready
// (will become a member of replica set and will finish data sync)
return exutil.WaitForQueryOutputContains(oc, mongoPod, 1*time.Minute, false, findCmd, `{ "status" : "passed" }`)
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:11,代码来源:mongodb_replica_petset.go
示例2: tryToReadFromPod
func tryToReadFromPod(oc *exutil.CLI, podName, expectedValue string) {
// don't include _id field to output because it changes every time
findCmd := "rs.slaveOk(); printjson(db.bar.find({}, {_id: 0}).toArray())"
fmt.Fprintf(g.GinkgoWriter, "DEBUG: reading record from pod %v\n", podName)
mongoPod := db.NewMongoDB(podName)
result, err := mongoPod.Query(oc, findCmd)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(result).Should(o.ContainSubstring(expectedValue))
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:11,代码来源:mongodb_replica.go
示例3:
}
o.Expect(err).ShouldNot(o.HaveOccurred())
g.By("expecting the mongodb pod is running")
podNames, err := exutil.WaitForPods(
oc.KubeREST().Pods(oc.Namespace()),
exutil.ParseLabelsOrDie("name=mongodb"),
exutil.CheckPodIsRunningFn,
1,
1*time.Minute,
)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(podNames).Should(o.HaveLen(1))
g.By("expecting the mongodb service is answering for ping")
mongo := db.NewMongoDB(podNames[0])
ok, err := mongo.IsReady(oc)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(ok).Should(o.BeTrue())
g.By("expecting that we can insert a new record")
result, err := mongo.Query(oc, `db.foo.save({ "status": "passed" })`)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(result).Should(o.ContainSubstring(`WriteResult({ "nInserted" : 1 })`))
g.By("expecting that we can read a record")
findCmd := "printjson(db.foo.find({}, {_id: 0}).toArray())" // don't include _id field to output because it changes every time
result, err = mongo.Query(oc, findCmd)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(result).Should(o.ContainSubstring(`{ "status" : "passed" }`))
})
开发者ID:RomainVabre,项目名称:origin,代码行数:31,代码来源:mongodb_ephemeral.go
示例4:
).Execute(),
).Should(o.Succeed())
g.By("waiting for pods to running")
podNames, err := exutil.WaitForPods(
oc.KubeREST().Pods(oc.Namespace()),
exutil.ParseLabelsOrDie("name=mongodb-replicaset"),
exutil.CheckPodIsRunningFn,
3,
2*time.Minute,
)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podNames).Should(o.HaveLen(3))
g.By("expecting that we can insert a new record on primary node")
mongo := dbutil.NewMongoDB(podNames[0])
replicaSet := mongo.(exutil.ReplicaSet)
_, err = replicaSet.QueryPrimary(oc, `db.test.save({ "status" : "passed" })`)
o.Expect(err).ShouldNot(o.HaveOccurred())
g.By("expecting that we can read a record from all members")
for _, podName := range podNames {
o.Expect(readRecordFromPod(oc, podName)).To(o.Succeed())
}
g.By("restarting replica set")
err = oc.Run("delete").Args("pods", "--all", "-n", oc.Namespace()).Execute()
o.Expect(err).ShouldNot(o.HaveOccurred())
g.By("waiting for restarting of the pods")
podNames, err = exutil.WaitForPods(
开发者ID:juanluisvaladas,项目名称:origin,代码行数:31,代码来源:mongodb_replica_petset.go
注:本文中的github.com/openshift/origin/test/extended/util/db.NewMongoDB函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论