Example #1
0
func (t *ETCDHelper) SetRawEvacuatingActualLRP(lrp *models.ActualLRP, ttlInSeconds uint64) {
	value, err := t.serializer.Marshal(t.logger, t.format, lrp)
	Expect(err).NotTo(HaveOccurred())

	key := etcddb.EvacuatingActualLRPSchemaPath(lrp.GetProcessGuid(), lrp.GetIndex())
	_, err = t.client.Set(key, value, ttlInSeconds)

	Expect(err).NotTo(HaveOccurred())
}
			_, err = storeClient.Set(deprecations.DesiredLRPSchemaPath(expectedDesiredLRP), jsonValue, 0)
			Expect(err).NotTo(HaveOccurred())

			// ActualLRP
			expectedActualLRP = model_helpers.NewValidActualLRP("process-guid", 1)
			jsonValue, err = json.Marshal(expectedActualLRP)
			Expect(err).NotTo(HaveOccurred())
			_, err = storeClient.Set(etcd.ActualLRPSchemaPath(expectedActualLRP.ProcessGuid, 1), jsonValue, 0)
			Expect(err).NotTo(HaveOccurred())

			// Evacuating ActualLRP
			expectedEvacuatingActualLRP = model_helpers.NewValidActualLRP("process-guid", 4)
			jsonValue, err = json.Marshal(expectedEvacuatingActualLRP)
			Expect(err).NotTo(HaveOccurred())
			_, err = storeClient.Set(
				etcd.EvacuatingActualLRPSchemaPath(expectedEvacuatingActualLRP.ProcessGuid, 1),
				jsonValue,
				0,
			)
			Expect(err).NotTo(HaveOccurred())

			// Tasks
			expectedTask = model_helpers.NewValidTask("task-guid")
			jsonValue, err = json.Marshal(expectedTask)
			Expect(err).NotTo(HaveOccurred())
			_, err = storeClient.Set(etcd.TaskSchemaPath(expectedTask), jsonValue, 0)
			Expect(err).NotTo(HaveOccurred())
		})

		JustBeforeEach(func() {
			migration.SetStoreClient(storeClient)
						ActualLRPNetInfo:     netInfoData,
						CrashCount:           actualLRP.CrashCount,
						CrashReason:          actualLRP.CrashReason,
						State:                actualLRP.State,
						PlacementError:       actualLRP.PlacementError,
						Since:                actualLRP.Since,
						ModificationTagEpoch: actualLRP.ModificationTag.Epoch,
						ModificationTagIndex: actualLRP.ModificationTag.Index,
					})
				}

				actualLRP := model_helpers.NewValidActualLRP("evacuating-lrp", 0)

				actualLRPData, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, actualLRP)
				Expect(err).NotTo(HaveOccurred())
				_, err = storeClient.Set(etcddb.EvacuatingActualLRPSchemaPath("evacuating-lrp", 0), actualLRPData, 0)
				Expect(err).NotTo(HaveOccurred())
			})

			It("only creates an actual lrp in sqldb for each /instance/ actual lrp in etcd", func() {
				Expect(migrationErr).NotTo(HaveOccurred())

				rows, err := rawSQLDB.Query(`
					SELECT
						process_guid, instance_index, domain, instance_guid, cell_id, net_info,
						crash_count, crash_reason, state, placement_error, since,
						modification_tag_epoch, modification_tag_index
					FROM actual_lrps
				`)
				Expect(err).NotTo(HaveOccurred())
				defer rows.Close()
Example #4
0
func (t *ETCDHelper) CreateMalformedEvacuatingLRP(guid string, index int32) {
	t.createMalformedValueForKey(etcddb.EvacuatingActualLRPSchemaPath(guid, index))
}
Example #5
0
		var (
			actualLRP *models.ActualLRP
			index     int32
			guid      string
			ttl       uint64
		)

		BeforeEach(func() {
			guid = "the-guid"
			index = 1
			ttl = 60
			actualLRP = model_helpers.NewValidActualLRP(guid, index)

			etcdHelper.SetRawEvacuatingActualLRP(actualLRP, ttl)

			node, err := storeClient.Get(etcd.EvacuatingActualLRPSchemaPath(guid, index), false, false)
			fakeStoreClient.GetReturns(node, err)
		})

		Context("when the something about the actual LRP has changed", func() {
			BeforeEach(func() {
				clock.IncrementBySeconds(5)
				actualLRP.Since = clock.Now().UnixNano()
			})

			Context("when the lrp key changes", func() {
				BeforeEach(func() {
					actualLRP.Domain = "some-other-domain"
				})

				It("persists the evacuating lrp in etcd", func() {