Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
xunliu committed Dec 11, 2024
1 parent ee3dc00 commit af8bcc8
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 52 deletions.
2 changes: 1 addition & 1 deletion clients/client-python/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ tasks {
envMap.putAll(mapOf(
"PROJECT_VERSION" to project.version,
"GRAVITINO_HOME" to project.rootDir.path + "/distribution/package",
"START_EXTERNAL_GRAVITINO" to "false",
"START_EXTERNAL_GRAVITINO" to "true",
"DOCKER_TEST" to dockerTest.toString(),
"GRAVITINO_CI_HIVE_DOCKER_IMAGE" to "apache/gravitino-ci:hive-0.1.13",
"GRAVITINO_OAUTH2_SAMPLE_SERVER" to "datastrato/sample-authorization-server:0.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
from random import randint
from typing import Dict
Expand All @@ -28,8 +27,9 @@
Fileset,
)
from gravitino.exceptions.base import GravitinoRuntimeException
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestCommonAuth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# under the License.

import os
import logging
import unittest
import sys
import requests
Expand All @@ -33,8 +32,9 @@
)
from tests.integration.containers.oauth2_container import OAuth2Container
from tests.integration.config import Config
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)

DOCKER_TEST = os.environ.get("DOCKER_TEST")

Expand All @@ -51,7 +51,6 @@ class TestOAuth2(IntegrationTestEnv, TestCommonAuth):

@classmethod
def setUpClass(cls):

cls._get_gravitino_home()

cls.oauth2_container = OAuth2Container()
Expand All @@ -75,7 +74,7 @@ def setUpClass(cls):
# append the hadoop conf to server
cls._append_conf(cls.config, cls.oauth2_conf_path)

IntegrationTestEnv.start_gravitino()
IntegrationTestEnv.restart_server()
cls.oauth2_token_provider = DefaultOAuth2TokenProvider(
f"{cls.oauth2_server_uri}", "test:test", "test", "oauth2/token"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os

from gravitino import (
Expand All @@ -26,8 +25,9 @@

from tests.integration.auth.test_auth_common import TestCommonAuth
from tests.integration.integration_test_env import IntegrationTestEnv
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestSimpleAuthClient(IntegrationTestEnv, TestCommonAuth):
Expand Down
24 changes: 8 additions & 16 deletions clients/client-python/tests/integration/integration_test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
import unittest
import subprocess
import time
import sys
import shutil

import requests

from gravitino.exceptions.base import GravitinoRuntimeException
from tests.integration.config import Config
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


def get_gravitino_server_version(**kwargs):
Expand Down Expand Up @@ -77,14 +76,15 @@ def setUpClass(cls):
logger.error("ERROR: Can't find online Gravitino server!")
return

cls.start_gravitino()
logger.info("Start integration test environment...")
cls.exec_gravitino("start")

if not check_gravitino_server_status():
logger.error("ERROR: Can't start Gravitino server!")
sys.exit(0)

@classmethod
def start_gravitino(cls):
def exec_gravitino(cls, *args):
cls._get_gravitino_home()
cls.gravitino_startup_script = os.path.join(
cls.gravitino_home, "bin/gravitino.sh"
Expand All @@ -108,7 +108,7 @@ def start_gravitino(cls):

# Start Gravitino Server
result = subprocess.run(
[cls.gravitino_startup_script, "start"],
[cls.gravitino_startup_script, *args],
capture_output=True,
text=True,
check=False,
Expand All @@ -124,16 +124,7 @@ def tearDownClass(cls):
return

logger.info("Stop integration test environment...")
result = subprocess.run(
[cls.gravitino_startup_script, "stop"],
capture_output=True,
text=True,
check=False,
)
if result.stdout:
logger.info("stdout: %s", result.stdout)
if result.stderr:
logger.info("stderr: %s", result.stderr)
cls.exec_gravitino("stop")

gravitino_server_running = True
for i in range(5):
Expand All @@ -152,6 +143,7 @@ def tearDownClass(cls):
@classmethod
def restart_server(cls):
logger.info("Restarting Gravitino server...")
cls.exec_gravitino("restart")

@classmethod
def _get_gravitino_home(cls):
Expand Down
6 changes: 2 additions & 4 deletions clients/client-python/tests/integration/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import logging
from random import randint

from gravitino import (
NameIdentifier,
GravitinoAdminClient,
Expand All @@ -30,10 +28,10 @@
CatalogAlreadyExistsException,
NoSuchCatalogException,
)

from tests.integration.integration_test_env import IntegrationTestEnv
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestCatalog(IntegrationTestEnv):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
# specific language governing permissions and limitations
# under the License.

import logging
from random import randint
from typing import Dict, List

from gravitino import (
NameIdentifier,
GravitinoAdminClient,
Expand All @@ -35,8 +33,9 @@
GravitinoRuntimeException,
)
from tests.integration.integration_test_env import IntegrationTestEnv
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestFilesetCatalog(IntegrationTestEnv):
Expand Down
5 changes: 2 additions & 3 deletions clients/client-python/tests/integration/test_gvfs_with_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
from random import randint
import unittest
Expand All @@ -24,6 +23,7 @@
from adlfs import AzureBlobFileSystem


from tests.logging_config import setup_logger
from tests.integration.test_gvfs_with_hdfs import TestGvfsWithHDFS
from gravitino import (
gvfs,
Expand All @@ -35,8 +35,7 @@
from gravitino.filesystem.gvfs_config import GVFSConfig
from gravitino.filesystem.gvfs import StorageType


logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


def azure_abs_is_prepared():
Expand Down
5 changes: 2 additions & 3 deletions clients/client-python/tests/integration/test_gvfs_with_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
from random import randint
import unittest

from gcsfs import GCSFileSystem


from tests.logging_config import setup_logger
from tests.integration.test_gvfs_with_hdfs import TestGvfsWithHDFS
from gravitino import (
gvfs,
Expand All @@ -33,7 +32,7 @@
from gravitino.exceptions.base import GravitinoRuntimeException
from gravitino.filesystem.gvfs_config import GVFSConfig

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


def oss_is_configured():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
# pylint: disable=protected-access

import base64
import logging
import os
import platform
import unittest
from random import randint
from typing import Dict

import pandas
import pyarrow as pa
import pyarrow.dataset as dt
Expand All @@ -46,8 +44,9 @@
from tests.integration.integration_test_env import IntegrationTestEnv
from tests.integration.containers.hdfs_container import HDFSContainer
from tests.integration.base_hadoop_env import BaseHadoopEnvironment
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)

DOCKER_TEST = os.environ.get("DOCKER_TEST")

Expand Down
7 changes: 3 additions & 4 deletions clients/client-python/tests/integration/test_gvfs_with_oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# specific language governing permissions and limitations
# under the License.

import logging

import os
from random import randint
import unittest


from ossfs import OSSFileSystem

from tests.logging_config import setup_logger
from tests.integration.test_gvfs_with_hdfs import TestGvfsWithHDFS
from gravitino import (
gvfs,
Expand All @@ -33,8 +33,7 @@
from gravitino.exceptions.base import GravitinoRuntimeException
from gravitino.filesystem.gvfs_config import GVFSConfig


logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


def oss_is_configured():
Expand Down
4 changes: 2 additions & 2 deletions clients/client-python/tests/integration/test_gvfs_with_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
from random import randint
import unittest

from s3fs import S3FileSystem

from tests.logging_config import setup_logger
from tests.integration.test_gvfs_with_hdfs import TestGvfsWithHDFS
from gravitino import (
gvfs,
Expand All @@ -32,7 +32,7 @@
from gravitino.exceptions.base import GravitinoRuntimeException
from gravitino.filesystem.gvfs_config import GVFSConfig

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


def s3_is_configured():
Expand Down
5 changes: 2 additions & 3 deletions clients/client-python/tests/integration/test_metalake.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import logging
from typing import Dict, List

from gravitino import GravitinoAdminClient, GravitinoMetalake, MetalakeChange
from gravitino.dto.dto_converters import DTOConverters
from gravitino.dto.requests.metalake_updates_request import MetalakeUpdatesRequest
Expand All @@ -27,8 +25,9 @@
MetalakeAlreadyExistsException,
)
from tests.integration.integration_test_env import IntegrationTestEnv
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestMetalake(IntegrationTestEnv):
Expand Down
4 changes: 2 additions & 2 deletions clients/client-python/tests/integration/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import logging
from random import randint
from typing import Dict, List

Expand All @@ -34,8 +33,9 @@
)

from tests.integration.integration_test_env import IntegrationTestEnv
from tests.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger(__name__)


class TestSchema(IntegrationTestEnv):
Expand Down
26 changes: 26 additions & 0 deletions clients/client-python/tests/logging_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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 logging


def setup_logger(name):
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s:%(lineno)d - %(levelname)s - %(message)s",
)
return logging.getLogger(name)

0 comments on commit af8bcc8

Please sign in to comment.