kytos / maintenance

Kytos Maintenance Window NApp
0 stars 12 forks source link

The return code on the end maintenance API call does not correspond with the info provided in the documentation #35

Open ArturoQuintana opened 3 years ago

ArturoQuintana commented 3 years ago

@hdiogenes @ajoaoff @rmotitsuki

It has been tested the API call /maintenance/{mw_id}/end on PATCH with the idea to execute an early end over a maintenance task that is running. Unfortunately, this task does not succeed. The test code used is as follow:

def test_040_end_mw_on_switch(self):
        # Setup maintenance window data
        start = datetime.now() + timedelta(seconds=60)
        end = start + timedelta(hours=1)
        payload = {
            "description": "mw for test 040",
            "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)

        api_url = KYTOS_API + '/maintenance/' + mw_id + '/end'
        request = requests.patch(api_url)
        assert request.status_code == 201`
ajoaoff commented 3 years ago

@ArturoQuintana, you created the maintenance to be started after 60 seconds, but you put a sleep of only 10 seconds, so the maintenance is not yet running at the time you call the API to end it.

ArturoQuintana commented 3 years ago

@ajoaoff, I have modified the code after your observation. The API code does work, but now I am receiving a 200 response; when should be a 201 following the documentation.