Ejemplo n.º 1
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)
Ejemplo n.º 2
0
    def test_delete_and_create_gsi(self):
        r = self.connection(
            _lv.UpdateTable("Aaa").delete_global_secondary_index("the_gsi"))
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].index_status,
            "DELETING")

        _lv.wait_for_table_activation(self.connection, "Aaa")

        r = self.connection(_lv.DescribeTable("Aaa"))
        self.assertEqual(r.table.global_secondary_indexes, None)
        self.assertEqual(
            len(r.table.attribute_definitions),
            1)  # The previous definition of attribute "hh" has disapeared.

        r = self.connection(
            _lv.UpdateTable("Aaa").create_global_secondary_index(
                "new_gsi").provisioned_throughput(1, 2).hash_key(
                    "nh", _lv.NUMBER).project_all())

        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.read_capacity_units, 1)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].
            provisioned_throughput.write_capacity_units, 2)
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].key_schema[0].
            attribute_name, "nh")
        self.assertEqual(
            r.table_description.global_secondary_indexes[0].key_schema[0].
            key_type, "HASH")
        self.assertEqual(len(r.table_description.attribute_definitions), 2)
 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 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")
 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")
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
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
Ejemplo n.º 9
0
    def test_delete_and_create_gsi(self):
        r = self.connection(_lv.UpdateTable("Aaa").delete_global_secondary_index("the_gsi"))
        self.assertEqual(r.table_description.global_secondary_indexes[0].index_status, "DELETING")

        _lv.wait_for_table_activation(self.connection, "Aaa")

        r = self.connection(_lv.DescribeTable("Aaa"))
        self.assertEqual(r.table.global_secondary_indexes, None)
        self.assertEqual(len(r.table.attribute_definitions), 1)  # The previous definition of attribute "hh" has disapeared.

        r = self.connection(
            _lv.UpdateTable("Aaa")
                .create_global_secondary_index("new_gsi")
                    .provisioned_throughput(1, 2)
                    .hash_key("nh", _lv.NUMBER)
                    .project_all()
        )

        self.assertEqual(r.table_description.global_secondary_indexes[0].provisioned_throughput.read_capacity_units, 1)
        self.assertEqual(r.table_description.global_secondary_indexes[0].provisioned_throughput.write_capacity_units, 2)
        self.assertEqual(r.table_description.global_secondary_indexes[0].key_schema[0].attribute_name, "nh")
        self.assertEqual(r.table_description.global_secondary_indexes[0].key_schema[0].key_type, "HASH")
        self.assertEqual(len(r.table_description.attribute_definitions), 2)
 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")
Ejemplo n.º 11
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
 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)