Esempio n. 1
0
 def setUp(self):
     super(ListTablesLocalIntegTests, self).setUp()
     self.connection(
         _lv.CreateTable("Aaa").hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 2))
     self.connection(
         _lv.CreateTable("Bbb").hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 2))
     self.connection(
         _lv.CreateTable("Ccc").hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 2))
Esempio n. 2
0
 def setUp(self):
     super(IterateListTablesLocalIntegTests, self).setUp()
     for t in self.table_names:
         self.connection(
             _lv.CreateTable(t).hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 1))
Esempio n. 3
0
 def setUp(self):
     super(WaitForTableDeletionConnectedIntegTests, self).setUp()
     self.table = self.make_table_name()
     self.connection(
         _lv.CreateTable(self.table).hash_key(
             "h", _lv.STRING).provisioned_throughput(1, 1))
     _lv.wait_for_table_activation(self.connection, self.table)
Esempio n. 4
0
    def test_simple_local_secondary_index(self):
        r = self.connection(
            _lv.CreateTable("Aaa").hash_key("h", _lv.STRING).range_key(
                "r", _lv.STRING).provisioned_throughput(
                    1, 2).local_secondary_index("the_lsi").hash_key(
                        "h").range_key("rr", _lv.STRING).project_all())

        self.assertEqual(
            r.table_description.local_secondary_indexes[0].index_name,
            "the_lsi")
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].index_size_bytes, 0)
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].item_count, 0)
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].key_schema[0].
            attribute_name, "h")
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].key_schema[0].
            key_type, "HASH")
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].key_schema[1].
            attribute_name, "rr")
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].key_schema[1].
            key_type, "RANGE")
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].projection.
            non_key_attributes, None)
        self.assertEqual(
            r.table_description.local_secondary_indexes[0].projection.
            projection_type, "ALL")
Esempio n. 5
0
    def test_simplest_table(self):
        r = self.connection(
            _lv.CreateTable("Aaa").hash_key("h",
                                            _lv.STRING).provisioned_throughput(
                                                1, 2))

        self.assertDateTimeIsReasonable(r.table_description.creation_date_time)
        self.assertEqual(
            r.table_description.attribute_definitions[0].attribute_name, "h")
        self.assertEqual(
            r.table_description.attribute_definitions[0].attribute_type, "S")
        self.assertEqual(r.table_description.global_secondary_indexes, None)
        self.assertEqual(r.table_description.item_count, 0)
        self.assertEqual(r.table_description.key_schema[0].attribute_name, "h")
        self.assertEqual(r.table_description.key_schema[0].key_type, "HASH")
        self.assertEqual(r.table_description.local_secondary_indexes, None)
        self.assertEqual(
            r.table_description.provisioned_throughput.last_decrease_date_time,
            datetime.datetime(1970, 1, 1))
        self.assertEqual(
            r.table_description.provisioned_throughput.last_increase_date_time,
            datetime.datetime(1970, 1, 1))
        self.assertEqual(
            r.table_description.provisioned_throughput.
            number_of_decreases_today, 0)
        self.assertEqual(
            r.table_description.provisioned_throughput.read_capacity_units, 1)
        self.assertEqual(
            r.table_description.provisioned_throughput.write_capacity_units, 2)
        self.assertEqual(r.table_description.table_name, "Aaa")
        self.assertEqual(r.table_description.table_size_bytes, 0)
        self.assertEqual(r.table_description.table_status, "ACTIVE")
Esempio n. 6
0
 def setUp(self):
     super(UpdateTableLocalIntegTests, self).setUp()
     self.connection(
         _lv.CreateTable("Aaa").hash_key(
             "h", _lv.STRING).provisioned_throughput(
                 1, 2).global_secondary_index("the_gsi").hash_key(
                     "hh",
                     _lv.STRING).project_all().provisioned_throughput(3, 4))
 def test(self):
     self.connection(
         _lv.CreateTable("Aaa").hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 1))
     _lv.wait_for_table_activation(self.connection, "Aaa")
     self.assertEqual(
         self.connection(_lv.DescribeTable("Aaa")).table.table_status,
         "ACTIVE")
Esempio n. 8
0
 def test_dont_define_any_attribute(self):
     with self.assertRaises(_lv.ValidationException) as catcher:
         self.connection(
             _lv.CreateTable("Aaa").hash_key("h").provisioned_throughput(
                 1, 2))
     self.assertEqual(
         catcher.exception.args, ({
             "__type": "com.amazon.coral.validate#ValidationException",
             "message": "No Attribute Schema Defined",
         }, ))
Esempio n. 9
0
 def test_dont_define_key_attribute(self):
     with self.assertRaises(_lv.ValidationException) as catcher:
         self.connection(
             _lv.CreateTable("Aaa").hash_key("h").provisioned_throughput(
                 1, 2).attribute_definition("x", _lv.STRING))
     self.assertEqual(catcher.exception.args, ({
         "__type":
         "com.amazon.coral.validate#ValidationException",
         "message":
         "Hash Key not specified in Attribute Definitions.  Type unknown.",
     }, ))
Esempio n. 10
0
 def test_define_unused_attribute(self):
     with self.assertRaises(_lv.ValidationException) as catcher:
         self.connection(
             _lv.CreateTable("Aaa").hash_key(
                 "h", _lv.STRING).provisioned_throughput(
                     1, 2).attribute_definition("x", _lv.STRING))
     self.assertEqual(catcher.exception.args, ({
         "__type":
         "com.amazon.coral.validate#ValidationException",
         "message":
         "The number of attributes in key schema must match the number of attributesdefined in attribute definitions.",
     }, ))
 def test(self):
     self.connection(
         _lv.CreateTable(self.table).hash_key("tab_h", _lv.STRING).
         range_key("tab_r", _lv.NUMBER).provisioned_throughput(
             1, 1).global_secondary_index("gsi").hash_key(
                 "gsi_h", _lv.STRING).range_key(
                     "gsi_r",
                     _lv.NUMBER).project_all().provisioned_throughput(1, 1))
     _lv.wait_for_table_activation(self.connection, self.table)
     r = self.connection(_lv.DescribeTable(self.table))
     self.assertEqual(r.table.table_status, "ACTIVE")
     self.assertEqual(r.table.global_secondary_indexes[0].index_status,
                      "ACTIVE")
    def make(self, dependencies):
        connection = make_connection()

        table = table_name_prefix

        connection(
            _lv.CreateTable(table).hash_key("tab_h", _lv.STRING).range_key(
                "tab_r", _lv.NUMBER).provisioned_throughput(
                    1, 1).global_secondary_index("gsi").hash_key(
                        "gsi_h", _lv.STRING).range_key("gsi_r", _lv.NUMBER).
            project_all().provisioned_throughput(
                1, 1).local_secondary_index("lsi").hash_key("tab_h").range_key(
                    "lsi_r",
                    _lv.NUMBER).project_all().provisioned_throughput(1, 1))
        _lv.wait_for_table_activation(connection, table)

        return table
Esempio n. 13
0
    def test_simple_global_secondary_index(self):
        r = self.connection(
            _lv.CreateTable("Aaa").hash_key(
                "h", _lv.STRING).provisioned_throughput(
                    1, 2).global_secondary_index("the_gsi").hash_key(
                        "hh",
                        _lv.STRING).project_all().provisioned_throughput(3, 4))

        self.assertEqual(
            r.table_description.global_secondary_indexes[0].index_name,
            "the_gsi")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].index_size_bytes,
            0)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].index_status,
            "ACTIVE")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].item_count, 0)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].key_schema[0].
            attribute_name, "hh")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].key_schema[0].
            key_type, "HASH")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].projection.
            non_key_attributes, None)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].projection.
            projection_type, "ALL")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.last_decrease_date_time, None)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.last_increase_date_time, None)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.number_of_decreases_today, None)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.read_capacity_units, 3)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.write_capacity_units, 4)
Esempio n. 14
0
    def test_global_secondary_index_with_projection(self):
        r = self.connection(
            _lv.CreateTable("Aaa").hash_key(
                "h", _lv.STRING).provisioned_throughput(
                    1, 2).global_secondary_index("the_gsi").hash_key(
                        "hh", _lv.STRING).project(
                            "toto", "titi").provisioned_throughput(3, 4))

        self.assertEqual(
            r.table_description.global_secondary_indexes[0].projection.
            non_key_attributes[0], "toto")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].projection.
            non_key_attributes[1], "titi")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].projection.
            projection_type, "INCLUDE")
Esempio n. 15
0
 def setUp(self):
     super(LocalIntegTestsWithTableHR, self).setUp()
     self.connection(
         _lv.CreateTable("Aaa").hash_key("h", _lv.STRING).range_key(
             "r", _lv.NUMBER).provisioned_throughput(1, 1))
Esempio n. 16
0
def global_setup():
    connection = _lv.Connection("us-west-2", _lv.EnvironmentCredentials())

    table1 = "LowVoltage.Tests.Doc.1"
    table2 = "LowVoltage.Tests.Doc.2"

    try:
        connection(_lv.DescribeTable(table1))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table).hash_key(
                "h", _lv.NUMBER).provisioned_throughput(
                    1, 1).global_secondary_index("gsi").hash_key(
                        "gh", _lv.NUMBER).range_key(
                            "gr", _lv.NUMBER).provisioned_throughput(
                                1, 1).project_all())

    try:
        connection(_lv.DescribeTable(table2))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table2).hash_key("h", _lv.NUMBER).range_key(
                "r1", _lv.NUMBER).provisioned_throughput(
                    1, 1).local_secondary_index("lsi").hash_key(
                        "h", _lv.NUMBER).range_key("r2",
                                                   _lv.NUMBER).project_all())

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{
            "h": h,
            "gh": h * h,
            "gr": 10 - 2 * h
        } for h in range(7)],
    )

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{
            "h": h,
            "a": 0
        } for h in range(7, 10)],
    )

    _lv.wait_for_table_activation(connection, table2)
    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": h,
            "r1": 0,
            "r2": 0
        } for h in range(10)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": 42,
            "r1": r1,
            "r2": 10 - r1
        } for r1 in range(6)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": 42,
            "r1": r1
        } for r1 in range(6, 10)],
    )

    return connection, table1, table2
Esempio n. 17
0
 def setUp(self):
     super(WaitForTableDeletionLocalIntegTests, self).setUp()
     self.connection(
         _lv.CreateTable("Aaa").hash_key("h",
                                         _lv.STRING).provisioned_throughput(
                                             1, 1))