mirror of https://github.com/google/oss-fuzz.git
Renaming infra/build/functions files (#4031)
Renamed main.py to sync.py and test_sync.py to sync_test.py Co-authored-by: Kabeer Seth <kabeerseth@google.com>
This commit is contained in:
parent
eaae983c73
commit
d15dc2a88f
|
@ -20,7 +20,19 @@ jobs:
|
||||||
python-version: 3.7
|
python-version: 3.7
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install -r infra/ci/requirements.txt
|
run:
|
||||||
|
pip install -r infra/ci/requirements.txt
|
||||||
|
pip install -r infra/build/functions/requirements.txt
|
||||||
|
|
||||||
|
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
||||||
|
with:
|
||||||
|
version: '298.0.0'
|
||||||
|
- run:
|
||||||
|
gcloud components install beta cloud-datastore-emulator &&
|
||||||
|
gcloud info
|
||||||
|
|
||||||
|
|
||||||
- name: Run infra tests
|
- name: Run infra tests
|
||||||
run: python infra/presubmit.py infra-tests
|
run: python infra/presubmit.py infra-tests
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,15 @@ import threading
|
||||||
|
|
||||||
from google.cloud import ndb
|
from google.cloud import ndb
|
||||||
|
|
||||||
from main import sync_projects
|
from sync import sync_projects
|
||||||
from main import get_projects
|
from sync import get_projects
|
||||||
from main import get_access_token
|
from sync import get_access_token
|
||||||
from main import Project
|
from sync import Project
|
||||||
|
|
||||||
_EMULATOR_TIMEOUT = 20
|
_EMULATOR_TIMEOUT = 20
|
||||||
_DATASTORE_READY_INDICATOR = b'is now running'
|
_DATASTORE_READY_INDICATOR = b'is now running'
|
||||||
|
_DATASTORE_EMULATOR_PORT = 8432
|
||||||
|
_TEST_PROJECT_ID = 'test-project'
|
||||||
|
|
||||||
|
|
||||||
def start_datastore_emulator():
|
def start_datastore_emulator():
|
||||||
|
@ -41,8 +43,8 @@ def start_datastore_emulator():
|
||||||
'datastore',
|
'datastore',
|
||||||
'start',
|
'start',
|
||||||
'--consistency=1.0',
|
'--consistency=1.0',
|
||||||
'--host-port=localhost:' + str(os.environ.get('DATASTORE_EMULATOR_PORT')),
|
'--host-port=localhost:' + str(_DATASTORE_EMULATOR_PORT),
|
||||||
'--project=' + os.environ.get('DATASTORE_PROJECT_ID'),
|
'--project=' + _TEST_PROJECT_ID,
|
||||||
'--no-store-on-disk',
|
'--no-store-on-disk',
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
@ -102,6 +104,16 @@ class Repository:
|
||||||
class TestDataSync(unittest.TestCase):
|
class TestDataSync(unittest.TestCase):
|
||||||
"""Unit tests for sync."""
|
"""Unit tests for sync."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
ds_emulator = start_datastore_emulator()
|
||||||
|
_wait_for_emulator_ready(ds_emulator, 'datastore',
|
||||||
|
_DATASTORE_READY_INDICATOR)
|
||||||
|
os.environ['DATASTORE_EMULATOR_HOST'] = 'localhost:' + str(
|
||||||
|
_DATASTORE_EMULATOR_PORT)
|
||||||
|
os.environ['GOOGLE_CLOUD_PROJECT'] = _TEST_PROJECT_ID
|
||||||
|
os.environ['DATASTORE_DATASET'] = _TEST_PROJECT_ID
|
||||||
|
|
||||||
def test_sync_projects(self):
|
def test_sync_projects(self):
|
||||||
"""Testing sync_projects()."""
|
"""Testing sync_projects()."""
|
||||||
client = ndb.Client()
|
client = ndb.Client()
|
||||||
|
@ -116,6 +128,8 @@ class TestDataSync(unittest.TestCase):
|
||||||
projects_query = Project.query()
|
projects_query = Project.query()
|
||||||
self.assertEqual(projects, {project.name for project in projects_query})
|
self.assertEqual(projects, {project.name for project in projects_query})
|
||||||
|
|
||||||
|
# Todo: Clean datastore in case of new tests relating to same entities.
|
||||||
|
|
||||||
def test_get_projects(self):
|
def test_get_projects(self):
|
||||||
"""Testing get_projects()."""
|
"""Testing get_projects()."""
|
||||||
|
|
||||||
|
@ -175,10 +189,12 @@ class TestDataSync(unittest.TestCase):
|
||||||
with client.context():
|
with client.context():
|
||||||
self.assertRaises(RuntimeError, get_access_token)
|
self.assertRaises(RuntimeError, get_access_token)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
# TODO: replace this with a cleaner way of killing the process
|
||||||
|
os.system('pkill -f datastore')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
DS_EMULATOR = start_datastore_emulator()
|
|
||||||
_wait_for_emulator_ready(DS_EMULATOR, 'datastore', _DATASTORE_READY_INDICATOR)
|
|
||||||
unittest.main(exit=False)
|
unittest.main(exit=False)
|
||||||
# TODO: replace this with a cleaner way of killing the process
|
|
||||||
os.system('pkill -f datastore')
|
|
Loading…
Reference in New Issue