Skip to content

Commit

Permalink
add e2e + temp uncomment management e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderWWW committed Sep 28, 2023
1 parent 14bad0f commit c0634ba
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 128 deletions.
240 changes: 120 additions & 120 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
schedule:
- cron: "0 4 * * *" # Run every day at arbitrary time (4:00 AM UTC)
push:
branches:
- master
# branches:
# - master

env:
WORKSPACE_NAME: e2e-tests
Expand All @@ -18,38 +18,38 @@ env:
SERVICE_ACCOUNT_NAME: ${{ secrets.E2E_SERVICE_ACCOUNT_NAME }}

jobs:
e2e:
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.7.16"
os: macos
- python-version: "3.10"
os: macos
runs-on: ${{ matrix.os }}-latest
name: 'standard (${{ matrix.os }} - py${{ matrix.python-version }})'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Test
uses: ./.github/actions/test-e2e
env:
NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
module: "not s3 and not integrations"
name: "standard"
report_job: 'standard (${{ matrix.os }} - py${{ matrix.python-version }})'
codecov-token: ${{ secrets.CODECOV_TOKEN }}
# e2e:
# timeout-minutes: 75
# strategy:
# fail-fast: false
# matrix:
# python-version: [ "3.7", "3.10" ]
# os: [ ubuntu, windows ]
# include:
# - python-version: "3.7.16"
# os: macos
# - python-version: "3.10"
# os: macos
# runs-on: ${{ matrix.os }}-latest
# name: 'standard (${{ matrix.os }} - py${{ matrix.python-version }})'
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: ${{ github.event.client_payload.pull_request.head.ref }}
#
# - name: Test
# uses: ./.github/actions/test-e2e
# env:
# NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
# with:
# python-version: ${{ matrix.python-version }}
# os: ${{ matrix.os }}
# module: "not s3 and not integrations"
# name: "standard"
# report_job: 'standard (${{ matrix.os }} - py${{ matrix.python-version }})'
# codecov-token: ${{ secrets.CODECOV_TOKEN }}

e2e_management:
timeout-minutes: 75
Expand Down Expand Up @@ -84,89 +84,89 @@ jobs:
report_job: 'management (${{ matrix.os }} - py${{ matrix.python-version }})'
codecov-token: ${{ secrets.CODECOV_TOKEN }}

e2e_s3_gcs:
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.7.16"
os: macos
- python-version: "3.10"
os: macos
runs-on: ${{ matrix.os }}-latest
name: 's3-gcs (${{ matrix.os }} - py${{ matrix.python-version }})'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Test
uses: ./.github/actions/test-e2e
env:
NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
AWS_ACCESS_KEY_ID: ${{secrets.E2E_GCS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.E2E_GCS_SECRET_ACCESS_KEY}}
S3_ENDPOINT_URL: "https://storage.googleapis.com/"
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
module: s3
name: s3-gcs
report_job: 's3-gcs (${{ matrix.os }} - py${{ matrix.python-version }})'
codecov-token: ${{ secrets.CODECOV_TOKEN }}

e2e_s3:
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.7.16"
os: macos
- python-version: "3.10"
os: macos
runs-on: ${{ matrix.os }}-latest
name: 's3 (${{ matrix.os }} - py${{ matrix.python-version }})'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Test
uses: ./.github/actions/test-e2e
env:
NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
AWS_ACCESS_KEY_ID: ${{secrets.E2E_AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.E2E_AWS_SECRET_ACCESS_KEY}}
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
module: s3
name: s3
report_job: 's3 (${{ matrix.os }} - py${{ matrix.python-version }})'
codecov-token: ${{ secrets.CODECOV_TOKEN }}

e2e-tests-notify:
needs: [ e2e, e2e_management, e2e_s3_gcs, e2e_s3 ]
runs-on: ubuntu-latest
if: (success() || failure()) && github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Notify
uses: ./.github/actions/workflow-notify
with:
slack-webhook: ${{ secrets.E2E_REGULAR_SLACK_WEBHOOK }}
# e2e_s3_gcs:
# timeout-minutes: 75
# strategy:
# fail-fast: false
# matrix:
# python-version: [ "3.7", "3.10" ]
# os: [ ubuntu, windows ]
# include:
# - python-version: "3.7.16"
# os: macos
# - python-version: "3.10"
# os: macos
# runs-on: ${{ matrix.os }}-latest
# name: 's3-gcs (${{ matrix.os }} - py${{ matrix.python-version }})'
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: ${{ github.event.client_payload.pull_request.head.ref }}
#
# - name: Test
# uses: ./.github/actions/test-e2e
# env:
# NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
# AWS_ACCESS_KEY_ID: ${{secrets.E2E_GCS_ACCESS_KEY_ID}}
# AWS_SECRET_ACCESS_KEY: ${{secrets.E2E_GCS_SECRET_ACCESS_KEY}}
# S3_ENDPOINT_URL: "https://storage.googleapis.com/"
# with:
# python-version: ${{ matrix.python-version }}
# os: ${{ matrix.os }}
# module: s3
# name: s3-gcs
# report_job: 's3-gcs (${{ matrix.os }} - py${{ matrix.python-version }})'
# codecov-token: ${{ secrets.CODECOV_TOKEN }}
#
# e2e_s3:
# timeout-minutes: 75
# strategy:
# fail-fast: false
# matrix:
# python-version: [ "3.7", "3.10" ]
# os: [ ubuntu, windows ]
# include:
# - python-version: "3.7.16"
# os: macos
# - python-version: "3.10"
# os: macos
# runs-on: ${{ matrix.os }}-latest
# name: 's3 (${{ matrix.os }} - py${{ matrix.python-version }})'
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: ${{ github.event.client_payload.pull_request.head.ref }}
#
# - name: Test
# uses: ./.github/actions/test-e2e
# env:
# NEPTUNE_API_TOKEN: ${{secrets.E2E_SERVICE_ACCOUNT_API_TOKEN}}
# AWS_ACCESS_KEY_ID: ${{secrets.E2E_AWS_ACCESS_KEY_ID}}
# AWS_SECRET_ACCESS_KEY: ${{secrets.E2E_AWS_SECRET_ACCESS_KEY}}
# with:
# python-version: ${{ matrix.python-version }}
# os: ${{ matrix.os }}
# module: s3
# name: s3
# report_job: 's3 (${{ matrix.os }} - py${{ matrix.python-version }})'
# codecov-token: ${{ secrets.CODECOV_TOKEN }}
#
# e2e-tests-notify:
# needs: [ e2e, e2e_management, e2e_s3_gcs, e2e_s3 ]
# runs-on: ubuntu-latest
# if: (success() || failure()) && github.ref == 'refs/heads/master'
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: ${{ github.event.client_payload.pull_request.head.ref }}
#
# - name: Notify
# uses: ./.github/actions/workflow-notify
# with:
# slack-webhook: ${{ secrets.E2E_REGULAR_SLACK_WEBHOOK }}
16 changes: 8 additions & 8 deletions src/neptune/management/internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def to_api(self) -> str:
def get_trashed_object_ids(project: Optional[str], api_token: Optional[str]) -> List[str]:
from neptune import init_project # to avoid circular imports

project_obj = init_project(project=project, api_token=api_token)
with init_project(project=project, api_token=api_token) as project_obj:

ids = []
ids = []

trashed_runs = project_obj.fetch_runs_table(trashed=True).to_rows()
if trashed_runs:
ids.extend([run.get_attribute_value("sys/id") for run in trashed_runs])
trashed_runs = project_obj.fetch_runs_table(trashed=True).to_rows()
if trashed_runs:
ids.extend([run.get_attribute_value("sys/id") for run in trashed_runs])

trashed_models = project_obj.fetch_models_table(trashed=True).to_rows()
if trashed_models:
ids.extend([model.get_attribute_value("sys/id") for model in trashed_models])
trashed_models = project_obj.fetch_models_table(trashed=True).to_rows()
if trashed_models:
ids.extend([model.get_attribute_value("sys/id") for model in trashed_models])

return ids
42 changes: 42 additions & 0 deletions tests/e2e/management/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import time
from typing import (
Callable,
Dict,
Expand All @@ -28,7 +29,9 @@
ProjectVisibility,
add_project_member,
add_project_service_account,
clear_trash,
create_project,
delete_objects_from_trash,
delete_project,
get_project_list,
get_project_member_list,
Expand Down Expand Up @@ -458,3 +461,42 @@ def wait_for_containers(self, ids: List[str], container_provider: Callable[[], T
fetched_entries = container_provider().to_pandas()
actual_ids = fetched_entries["sys/id"].tolist() if len(fetched_entries) > 0 else []
assert sorted(actual_ids) == sorted(ids)


@pytest.mark.management
class TestDeleteFromTrash:
def test_delete_from_trash(self, environment):
# given
run1 = initialize_container(ContainerType.RUN, project=environment.project)
run2 = initialize_container(ContainerType.RUN, project=environment.project)
model = initialize_container(ContainerType.MODEL, project=environment.project)
run_id_1 = run1["sys/id"].fetch()
run_id_2 = run2["sys/id"].fetch()
model_id = model["sys/id"].fetch()
time.sleep(5)

trash_objects(environment.project, [run_id_1, run_id_2, model_id])
time.sleep(5) # after that we should have 3 trashed objects

with initialize_container(ContainerType.PROJECT, project=environment.project) as project:
# when
delete_objects_from_trash(environment.project, [run_id_1])
time.sleep(5)

# then
trashed_runs = project.fetch_runs_table(trashed=True).to_rows()
assert len(trashed_runs) == 1

trashed_models = project.fetch_models_table(trashed=True).to_rows()
assert len(trashed_models) == 1

# when
clear_trash(environment.project)
time.sleep(5)

# then
trashed_runs = project.fetch_runs_table(trashed=True).to_rows()
assert len(trashed_runs) == 0

trashed_models = project.fetch_models_table(trashed=True).to_rows()
assert len(trashed_models) == 0

0 comments on commit c0634ba

Please sign in to comment.