Esempio n. 1
0
func (t *ETCDHelper) SetRawActualLRP(lrp *models.ActualLRP) {
	value, err := t.serializer.Marshal(t.logger, t.format, lrp)
	Expect(err).NotTo(HaveOccurred())

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

	Expect(err).NotTo(HaveOccurred())
}
Esempio n. 2
0
func (t *ETCDHelper) GetInstanceActualLRP(lrpKey *models.ActualLRPKey) (*models.ActualLRP, error) {
	resp, err := t.client.Get(etcd.ActualLRPSchemaPath(lrpKey.ProcessGuid, lrpKey.Index), false, false)
	if etcdErr, ok := err.(*etcdclient.EtcdError); ok && etcdErr.ErrorCode == etcd.ETCDErrKeyNotFound {
		return &models.ActualLRP{}, models.ErrResourceNotFound
	}

	Expect(err).NotTo(HaveOccurred())

	var lrp models.ActualLRP
	err = t.serializer.Unmarshal(t.logger, []byte(resp.Node.Value), &lrp)
	Expect(err).NotTo(HaveOccurred())

	return &lrp, nil
}
			migrationErr                                   error
		)

		BeforeEach(func() {
			// DesiredLRP
			expectedDesiredLRP = model_helpers.NewValidDesiredLRP("process-guid")
			jsonValue, err := json.Marshal(expectedDesiredLRP)
			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")
Esempio n. 4
0
func (t *ETCDHelper) DeleteActualLRP(guid string, index int32) {
	key := etcd.ActualLRPSchemaPath(guid, index)
	_, err := t.client.Delete(key, false)
	Expect(err).NotTo(HaveOccurred())
}
Esempio n. 5
0
func (t *ETCDHelper) CreateMalformedActualLRP(guid string, index int32) {
	t.createMalformedValueForKey(etcddb.ActualLRPSchemaPath(guid, index))
}
		Describe("Actual LRPs", func() {
			var (
				existingActualLRPs   []migrations.ETCDToSQLActualLRP
				instanceLRPsToCreate int
			)

			BeforeEach(func() {
				instanceLRPsToCreate = 3
				for i := 0; i < instanceLRPsToCreate; i++ {
					processGuid := fmt.Sprintf("process-guid-%d", i)
					actualLRP := model_helpers.NewValidActualLRP(processGuid, int32(i))

					actualLRPData, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, actualLRP)
					Expect(err).NotTo(HaveOccurred())
					_, err = storeClient.Set(etcddb.ActualLRPSchemaPath(processGuid, int32(i)), actualLRPData, 0)
					Expect(err).NotTo(HaveOccurred())

					encoder := format.NewEncoder(cryptor)
					encryptedNetInfo, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, &actualLRP.ActualLRPNetInfo)
					Expect(err).NotTo(HaveOccurred())
					netInfoData, err := encoder.Decode(encryptedNetInfo)
					Expect(err).NotTo(HaveOccurred())

					existingActualLRPs = append(existingActualLRPs, migrations.ETCDToSQLActualLRP{
						ProcessGuid:          actualLRP.ProcessGuid,
						Index:                actualLRP.Index,
						Domain:               actualLRP.Domain,
						InstanceGuid:         actualLRP.InstanceGuid,
						CellId:               actualLRP.CellId,
						ActualLRPNetInfo:     netInfoData,