Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: appengine/cmd/dm/model/execution_test.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/cmd/dm/model/execution_test.go
diff --git a/appengine/cmd/dm/model/execution_test.go b/appengine/cmd/dm/model/execution_test.go
index 619ab63adbf9184897e2fa0379e57678735f646b..2a59203bdd6c57741c485a9635b363cff90f1cc7 100644
--- a/appengine/cmd/dm/model/execution_test.go
+++ b/appengine/cmd/dm/model/execution_test.go
@@ -35,7 +35,7 @@ func TestExecutions(t *testing.T) {
ak := ds.KeyForObj(a)
Convey("Revoke", func() {
- e1 := &Execution{ID: 1, Attempt: ak, Token: []byte("good tok")}
+ e1 := &Execution{ID: 1, Attempt: ak, Token: []byte("good tok"), State: dm.Execution_RUNNING}
So(ds.Put(e1), ShouldBeNil)
e2 := *e1
@@ -56,7 +56,7 @@ func TestExecutions(t *testing.T) {
}
_, _, err := AuthenticateExecution(c, auth)
- So(err, ShouldBeRPCUnauthenticated, "execution Auth")
+ So(err, ShouldBeRPCInternal, "execution Auth")
So(ds.Put(a), ShouldBeNil)
_, _, err = AuthenticateExecution(c, auth)
@@ -102,7 +102,7 @@ func TestExecutions(t *testing.T) {
Convey("wrong execution id", func() {
auth.Id.Id++
_, _, err := ActivateExecution(c, auth, []byte("wrong tok"))
- So(err, ShouldBeRPCUnauthenticated, "execution Auth")
+ So(err, ShouldBeRPCInternal, "execution Auth")
})
Convey("attempt bad state", func() {
@@ -115,7 +115,7 @@ func TestExecutions(t *testing.T) {
So(ds.Put(a), ShouldBeNil)
Convey("wrong execution state", func() {
- e1.State = dm.Execution_CANCELLED
+ e1.State = dm.Execution_STOPPING
So(ds.Put(e1), ShouldBeNil)
_, _, err := ActivateExecution(c, auth, []byte("wrong token"))
So(err, ShouldBeRPCUnauthenticated, "execution Auth")
@@ -128,9 +128,7 @@ func TestExecutions(t *testing.T) {
Convey("correct token", func() {
auth.Token = []byte("good tok")
- memlogger.Reset(c)
newA, e, err := ActivateExecution(c, auth, []byte("new token"))
- memlogger.MustDumpStdout(c)
So(err, ShouldBeNil)
So(newA, ShouldResemble, a)
So(e.State, ShouldEqual, dm.Execution_RUNNING)
@@ -203,7 +201,7 @@ func TestExecutions(t *testing.T) {
fb.BreakFeatures(nil, "PutMulti")
_, _, err := InvalidateExecution(c, auth)
- So(err, ShouldBeRPCInternal, "unable to invalidate Auth")
+ So(err, ShouldBeRPCUnauthenticated, "unable to invalidate Auth")
fb.UnbreakFeatures("PutMulti")
@@ -229,36 +227,30 @@ func TestExecutionToProto(t *testing.T) {
ID: 1,
Attempt: ds.MakeKey("Attempt", "qst|fffffffe"),
- StateReason: "scheduled by DM",
-
Created: testclock.TestTimeUTC,
+ Modified: testclock.TestTimeUTC,
DistributorToken: "id",
- DistributorURL: "https://thing.place.example.com/task/id",
Token: []byte("secret"),
}
Convey("no id", func() {
- So(e.ToProto(false), ShouldResemble, &dm.Execution{Data: &dm.Execution_Data{
- State: dm.Execution_SCHEDULED,
- StateReason: "scheduled by DM",
- Created: google.NewTimestamp(testclock.TestTimeUTC),
- DistributorToken: "id",
- DistributorInfoUrl: "https://thing.place.example.com/task/id",
- }})
+ exp := dm.NewExecutionScheduling()
+ exp.Data.Created = google.NewTimestamp(testclock.TestTimeUTC)
+ exp.Data.Modified = google.NewTimestamp(testclock.TestTimeUTC)
+ exp.Data.DistributorInfo = &dm.Execution_Data_DistributorInfo{Token: "id"}
+
+ So(e.ToProto(false), ShouldResemble, exp)
})
Convey("with id", func() {
- So(e.ToProto(true), ShouldResemble, &dm.Execution{
- Id: dm.NewExecutionID("qst", 1, 1),
- Data: &dm.Execution_Data{
- State: dm.Execution_SCHEDULED,
- StateReason: "scheduled by DM",
- Created: google.NewTimestamp(testclock.TestTimeUTC),
- DistributorToken: "id",
- DistributorInfoUrl: "https://thing.place.example.com/task/id",
- },
- })
+ exp := dm.NewExecutionScheduling()
+ exp.Id = dm.NewExecutionID("qst", 1, 1)
+ exp.Data.Created = google.NewTimestamp(testclock.TestTimeUTC)
+ exp.Data.Modified = google.NewTimestamp(testclock.TestTimeUTC)
+ exp.Data.DistributorInfo = &dm.Execution_Data_DistributorInfo{Token: "id"}
+
+ So(e.ToProto(true), ShouldResemble, exp)
})
})
}

Powered by Google App Engine
This is Rietveld 408576698