[ARVADOS] updated: 2.1.0-216-ge04e1067e
Git user
git at public.arvados.org
Fri Dec 11 20:47:03 UTC 2020
Summary of changes:
lib/controller/federation_test.go | 72 +++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 30 deletions(-)
via e04e1067e0782da78eb5b56d3b11972d50e9b3b8 (commit)
from 79023a1d7b85cad4acc599edadaa70f201f0afe1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit e04e1067e0782da78eb5b56d3b11972d50e9b3b8
Author: Nico Cesar <nico at nicocesar.com>
Date: Fri Dec 11 15:46:40 2020 -0500
first commit with all test passing
Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>
diff --git a/lib/controller/federation_test.go b/lib/controller/federation_test.go
index 8a4839f0e..37d7007e7 100644
--- a/lib/controller/federation_test.go
+++ b/lib/controller/federation_test.go
@@ -11,7 +11,6 @@ import (
"fmt"
"io"
"io/ioutil"
- "log"
"net/http"
"net/http/httptest"
"net/url"
@@ -634,8 +633,7 @@ func (s *FederationSuite) TestCreateRemoteContainerRequest(c *check.C) {
c.Check(strings.HasPrefix(cr.UUID, "zzzzz-"), check.Equals, true)
}
-func (s *FederationSuite) TestCreateRemoteContainerRequestCheckRuntimeToken1(c *check.C) {
- s.remoteMockRequests = nil
+func (s *FederationSuite) TestCreateRemoteContainerRequestCheckRuntimeToken(c *check.C) {
// Send request to zmock and check that outgoing request has
// runtime_token set with a new random v2 token.
@@ -668,29 +666,34 @@ func (s *FederationSuite) TestCreateRemoteContainerRequestCheckRuntimeToken1(c *
var cr arvados.ContainerRequest
// Body can be a json formated or something like:
- // cluster_id=zmock&container_request=%7B%22command%22%3A%5B%22abc%22%5D%2C%22container_image%22%3A%22123%22%2C%22...7D
+ // (forceLegacyAPI14==false) cluster_id=zmock&container_request=%7B%22command%22%3A%5B%22abc%22%5D%2C%22container_image%22%3A%22123%22%2C%22...7D
+ // or:
+ // (forceLegacyAPI14==true) "{\"container_request\":{\"command\":[\"abc\"],\"container_image\":\"12...Uncommitted\"}}"
data, err := ioutil.ReadAll(s.remoteMockRequests[0].Body)
c.Check(err, check.IsNil)
- // decodedValue is somethikng like:
- // {"container_request":{"command":["abc"],"container_image":"123","name":"hello world",...}
- // but we have to eliminate 'cluster_id=zmock'
- // for some reason url.ParseQuery(string(data)) doesn't have the desired effect becausethe value is an JSON object instead of a string
- //escapedQuery := strings.TrimPrefix(string(data), "cluster_id=zmock&container_request=")
- //decodedValue, err := url.QueryUnescape(escapedQuery)
- decodedValue, err := url.ParseQuery(string(data))
- decodedValueCR := decodedValue.Get("container_request")
- log.Println(decodedValue)
- c.Check(err, check.IsNil)
- log.Printf("dvCR: %s", decodedValueCR)
- c.Check(json.Unmarshal([]byte(decodedValueCR), &cr), check.IsNil)
+
+ // this exposes the different inputs we get in the mock
+ if forceLegacyAPI14 {
+ var answerCR struct {
+ ContainerRequest arvados.ContainerRequest `json:"container_request"`
+ }
+ c.Check(json.Unmarshal(data, &answerCR), check.IsNil)
+ cr = answerCR.ContainerRequest
+ } else {
+ var decodedValueCR string
+ decodedValue, err := url.ParseQuery(string(data))
+ c.Check(err, check.IsNil)
+ decodedValueCR = decodedValue.Get("container_request")
+ c.Check(json.Unmarshal([]byte(decodedValueCR), &cr), check.IsNil)
+ }
+
// let's make sure the Runtime token is there
c.Check(strings.HasPrefix(cr.RuntimeToken, "v2/zzzzz-gj3su-"), check.Equals, true)
// the Runtimetoken should be a different one than than the Token we originally did the request with.
c.Check(cr.RuntimeToken, check.Not(check.Equals), arvadostest.ActiveTokenV2)
}
-func (s *FederationSuite) TestCreateRemoteContainerRequestCheckSetRuntimeToken2(c *check.C) {
- s.remoteMockRequests = nil
+func (s *FederationSuite) TestCreateRemoteContainerRequestCheckSetRuntimeToken(c *check.C) {
// Send request to zmock and check that outgoing request has
// runtime_token set with the explicitly provided token.
@@ -714,21 +717,30 @@ func (s *FederationSuite) TestCreateRemoteContainerRequestCheckSetRuntimeToken2(
resp := s.testRequest(req).Result()
c.Check(resp.StatusCode, check.Equals, http.StatusOK)
var cr arvados.ContainerRequest
+
// Body can be a json formated or something like:
- // cluster_id=zmock&container_request=%7B%22command%22%3A%5B%22abc%22%5D%2C%22container_image%22%3A%22123%22%2C%22...7D
+ // (forceLegacyAPI14==false) cluster_id=zmock&container_request=%7B%22command%22%3A%5B%22abc%22%5D%2C%22container_image%22%3A%22123%22%2C%22...7D
+ // or:
+ // (forceLegacyAPI14==true) "{\"container_request\":{\"command\":[\"abc\"],\"container_image\":\"12...Uncommitted\"}}"
data, err := ioutil.ReadAll(s.remoteMockRequests[0].Body)
c.Check(err, check.IsNil)
- // decodedValue is somethikng like:
- // {"container_request":{"command":["abc"],"container_image":"123","name":"hello world",...}
- // but we have to eliminate 'cluster_id=zmock'
- // for some reason url.ParseQuery(string(data)) doesn't have the desired effect becausethe value is an JSON object instead of a string
- //escapedQuery := strings.TrimPrefix(string(data), "cluster_id=zmock&container_request=")
- decodedValue, err := url.ParseQuery(string(data))
- log.Printf(">> decodedValues: %#v", decodedValue)
- decodedValueCR := decodedValue.Get("container_request")
- c.Check(err, check.IsNil)
- c.Check(json.Unmarshal([]byte(decodedValueCR), &cr), check.IsNil)
- log.Printf(">>> CR: %#v\n>>>JSON string: %s", cr, decodedValueCR)
+
+ // this exposes the different inputs we get in the mock
+ if forceLegacyAPI14 {
+ var answerCR struct {
+ ContainerRequest arvados.ContainerRequest `json:"container_request"`
+ }
+ c.Check(json.Unmarshal(data, &answerCR), check.IsNil)
+ cr = answerCR.ContainerRequest
+ } else {
+ var decodedValueCR string
+ decodedValue, err := url.ParseQuery(string(data))
+ c.Check(err, check.IsNil)
+ decodedValueCR = decodedValue.Get("container_request")
+ c.Check(json.Unmarshal([]byte(decodedValueCR), &cr), check.IsNil)
+ }
+
+ // After mocking around now making sure the runtime_token we sent is still there.
c.Check(cr.RuntimeToken, check.Equals, "xyz")
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list