It("translates the timeoutMs to timeout", func() {
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
					response := models.DesiredLRPsResponse{}
					err := response.Unmarshal(responseRecorder.Body.Bytes())
					Expect(err).NotTo(HaveOccurred())

					Expect(response.Error).To(BeNil())
					Expect(response.DesiredLrps).To(HaveLen(2))
					Expect(response.DesiredLrps[0]).To(Equal(desiredLRP1.VersionDownTo(format.V0)))
					Expect(response.DesiredLrps[1]).To(Equal(desiredLRP2.VersionDownTo(format.V0)))
				})
			})

			Context("and the desired LRPs have startTimeout not start_timeout_ms", func() {
				BeforeEach(func() {
					desiredLRP1.StartTimeoutMs = 10000
					desiredLRP2.StartTimeoutMs = 20000
				})

				It("translates StringTimeoutMs to StartTimeout", func() {
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
					response := models.DesiredLRPsResponse{}
					err := response.Unmarshal(responseRecorder.Body.Bytes())
					Expect(err).NotTo(HaveOccurred())

					Expect(response.Error).To(BeNil())
					Expect(response.DesiredLrps).To(HaveLen(2))
					Expect(response.DesiredLrps[0]).To(Equal(desiredLRP1.VersionDownTo(format.V0)))
					Expect(response.DesiredLrps[1]).To(Equal(desiredLRP2.VersionDownTo(format.V0)))
				})
			})
Exemplo n.º 2
0
				))
				desiredLRP.Action = models.WrapAction(models.Timeout(
					&models.RunAction{
						Path: "/the/path",
						User: "******",
					},
					20*time.Millisecond,
				))
				desiredLRP.Monitor = models.WrapAction(models.Timeout(
					&models.RunAction{
						Path: "/the/path",
						User: "******",
					},
					30*time.Millisecond,
				))
				desiredLRP.StartTimeoutMs = 10000
			})

			It("converts TimeoutMs to Timeout in Nanoseconds", func() {
				desiredLRP.VersionDownTo(format.V1)
				Expect(desiredLRP.GetSetup().GetTimeoutAction().DeprecatedTimeoutNs).To(BeEquivalentTo(10 * time.Millisecond))
				Expect(desiredLRP.GetAction().GetTimeoutAction().DeprecatedTimeoutNs).To(BeEquivalentTo(20 * time.Millisecond))
				Expect(desiredLRP.GetMonitor().GetTimeoutAction().DeprecatedTimeoutNs).To(BeEquivalentTo(30 * time.Millisecond))
			})

			It("converts StartTimeoutMs to StartTimeout in seconds", func() {
				desiredLRP.VersionDownTo(format.V1)
				Expect(desiredLRP.GetDeprecatedStartTimeoutS()).To(BeEquivalentTo(10))
			})
		})