kytos / maintenance

Kytos Maintenance Window NApp
0 stars 12 forks source link

We are able to delete a maintenance that is running #36

Closed ArturoQuintana closed 3 years ago

ArturoQuintana commented 3 years ago

@hdiogenes @ajoaoff @rmotitsuki It has been tested the API call /maintenance/{mw_id} on DELETE with the idea to execute a delete over a maintenance task that is running looking for a failing result as suppose to. Unfortunately, this task succeeded, meaning that it is possible to delete a running maintenance task. The test code used is as follow:

# Setup maintenance window data
        start = datetime.now() + timedelta(seconds=60)
        end = start + timedelta(seconds=60)
        payload = {
            "description": "mw for test 050",
            "start": start.strftime(TIME_FMT),
            "end": end.strftime(TIME_FMT),
            "items": [
                "00:00:00:00:00:00:00:02"
            ]
        }

        # Request maintenance schema creation, and extract the mw_id
        json_data = self.request_maintenance(payload, False)
        mw_id = json_data["mw_id"]

        time.sleep(10)

        # Delete maintenance mw_id
        api_url = KYTOS_API + '/maintenance/' + mw_id
        delete_response = requests.delete(api_url)
        assert delete_response.status_code == 200

        # Get maintenance schemas (it should be empty)
        json_data = self.get_maintenance_schema()
        assert json_data == []