Search in sources :

Example 26 with WorkloadRecord

use of com.yahoo.athenz.common.server.workload.WorkloadRecord in project athenz by yahoo.

the class DynamoDBWorkloadRecordStoreConnectionTest method testUpdateWorkloadRecordException.

@Test
public void testUpdateWorkloadRecordException() {
    WorkloadRecord workloadRecord = new WorkloadRecord();
    Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).updateItem(ArgumentMatchers.any(UpdateItemSpec.class));
    DynamoDBWorkloadRecordStoreConnection dbConn = getDBConnection();
    boolean requestSuccess = dbConn.updateWorkloadRecord(workloadRecord);
    Assert.assertFalse(requestSuccess);
    dbConn.close();
}
Also used : AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) UpdateItemSpec(com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec) WorkloadRecord(com.yahoo.athenz.common.server.workload.WorkloadRecord) Test(org.testng.annotations.Test)

Example 27 with WorkloadRecord

use of com.yahoo.athenz.common.server.workload.WorkloadRecord in project athenz by yahoo.

the class DynamoDBWorkloadRecordStoreConnection method itemToWorkloadRecord.

private WorkloadRecord itemToWorkloadRecord(Item item) {
    WorkloadRecord workloadRecord = new WorkloadRecord();
    workloadRecord.setInstanceId(item.getString(KEY_INSTANCE_ID));
    workloadRecord.setService(item.getString(KEY_SERVICE));
    workloadRecord.setIp(item.getString(KEY_IP));
    if (item.hasAttribute(KEY_HOSTNAME)) {
        workloadRecord.setHostname(item.getString(KEY_HOSTNAME));
    } else {
        workloadRecord.setHostname(DEFAULT_HOSTNAME_IF_NULL);
    }
    workloadRecord.setProvider(item.getString(KEY_PROVIDER));
    workloadRecord.setCreationTime(DynamoDBUtils.getDateFromItem(item, KEY_CREATION_TIME));
    workloadRecord.setUpdateTime(DynamoDBUtils.getDateFromItem(item, KEY_UPDATE_TIME));
    if (item.hasAttribute(KEY_EXPIRY_TIME)) {
        workloadRecord.setCertExpiryTime(DynamoDBUtils.getDateFromItem(item, KEY_EXPIRY_TIME));
    } else {
        // setting default date to 01/01/1970.
        workloadRecord.setCertExpiryTime(new Date(0));
    }
    return workloadRecord;
}
Also used : WorkloadRecord(com.yahoo.athenz.common.server.workload.WorkloadRecord) Date(java.util.Date)

Aggregations

WorkloadRecord (com.yahoo.athenz.common.server.workload.WorkloadRecord)27 Test (org.testng.annotations.Test)18 Date (java.util.Date)12 QuerySpec (com.amazonaws.services.dynamodbv2.document.spec.QuerySpec)4 AmazonDynamoDBException (com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException)4 WorkloadRecordStore (com.yahoo.athenz.common.server.workload.WorkloadRecordStore)3 WorkloadRecordStoreConnection (com.yahoo.athenz.common.server.workload.WorkloadRecordStoreConnection)3 UpdateItemSpec (com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec)2 java.sql (java.sql)2 ArrayList (java.util.ArrayList)2 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InetAddresses (com.google.common.net.InetAddresses)1 Authority (com.yahoo.athenz.auth.Authority)1 Authorizer (com.yahoo.athenz.auth.Authorizer)1 Principal (com.yahoo.athenz.auth.Principal)1 PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)1 AthenzUtils (com.yahoo.athenz.auth.util.AthenzUtils)1 Crypto (com.yahoo.athenz.auth.util.Crypto)1 CryptoException (com.yahoo.athenz.auth.util.CryptoException)1