☁️2024,2025☁️/Openstack

Openstack 기여하기 #4

리촬리 2024. 10. 4. 16:40
728x90

저번에 어디까지했는지 당최 기억이안나서 간만에 적어본다.

메인테이너이신 스테판님을 직접 만난뒤로 리뷰가 달렸다.

 

리뷰에서 수정사항을 제시하고 + functional test 코드를 요구하셔서

수정사항 제시받은것 먼저 컨벤션을 맞춰준다.

 

글구,, 예전의 나는 왜 유닛테스트중에 테스트 프록시는 수정하지 않았었을까?

근데 메인테이너님이 따로 지적 안해주셨으니 그냥 ..일단 안해야지

 

functional 테스트 코드는 이런식으로 짰다. (물론 zone 코드의 도움을 받았다.)

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import random

from openstack import connection
from openstack.tests.functional import base


class TestPool(base.BaseFunctionalTest):

    def setUp(self):
        super().setUp()
        self.require_service('dns')
        if not self.user_cloud:
            self.skipTest("The demo cloud is required for this test")

        self.conn = connection.from_config(cloud_name=base.TEST_CLOUD_NAME)
        self.POOL_NAME = f'example-{random.randint(1, 10000)}'
        self.pool = self.conn.dns.create_pool(
            name=self.POOL_NAME,
            description='example pool',
            ns_records=[
                {'hostname': 'ns1.example.org.', 'priority': 1},
                {'hostname': 'ns2.example.org.', 'priority': 2},
            ]
        )
        self.addCleanup(
            self.conn.dns.delete_pool,
            self.pool,
            delete_shares=True,
        )

    def test_get_pool(self):
        pool = self.conn.dns.get_pool(self.pool)
        self.assertEqual(self.pool, pool)

    def test_list_pools(self):
        names = [f.name for f in self.conn.dns.pools()]
        self.assertIn(self.POOL_NAME, names)

 

난 사실 멘토님이 물론 알려주셨었지만,, functional test 랑 유닛테스트의 차이를 아직도 ㅈ..잘 모른다 ^^

짧디 짧은 경험으로 느껴보기엔 구현의 차이인것같다.

아래는 내가 짠 유닛테스트 코드이다.

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack.dns.v2 import pool
from openstack.tests.unit import base

IDENTIFIER = 'NAME'
EXAMPLE = {
    "description": 'null',
    "id": IDENTIFIER,
    "project_id": "noauth-project",
    "created_at": "2015-02-23T21:56:33.000000",
    "attributes": 'null',
    "ns_records": [{"hostname": "ns2.example.org.", "priority": 1}],
    "links": {
        "self": "http://127.0.0.1:9001/v2/pools/d1716333-8c16-490f-85ee-29af36907605"
    },
    "name": "example_pool",
    "updated_at": 'null',
}


class TestPool(base.TestCase):
    def test_basic(self):
        sot = pool.Pool()
        self.assertEqual(None, sot.resource_key)
        self.assertEqual('pools', sot.resources_key)
        self.assertEqual('/pools', sot.base_path)
        self.assertTrue(sot.allow_list)

        self.assertEqual('GET', sot.commit_method)

 

여튼 

tox -e functional 명령어로 돌려보면, 

결과가 나오는데

 

으음 에러의 축복이 끝이없네

그리고 이건 .. 서버연결이 안되는거아닌강..?

 

오류 발생이슈로 인해 남은 오류는 멘토님께 질의하여 한번 해결해보겠다.

이것만 해결하면!!! 

다시 패치셋 올리고!!

머지가 코앞이다아아아~~~~!

 

 

오류가.. 리소스 관련 문제라고는 하는데 내 코드에서 문제는 따로 안나와있어서..

멘토님께 여쭤봐야지..

https://zuul.opendev.org/t/openstack/build/6426beee00fb41fa890d871d798c680c

 

Zuul

 

zuul.opendev.org

 

728x90