Skip to content

Commit 1cc8b97

Browse files
authored
Merge pull request Open-MSS#2974 from Open-MSS/merge_stable_to_develop
Merge stable to develop
2 parents 25d8394 + 9d1992f commit 1cc8b97

File tree

7 files changed

+49
-19
lines changed

7 files changed

+49
-19
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
steps:
7575
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
7676
- name: Ensure SHA pinned actions
77-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@fc87bb5b5a97953d987372e74478de634726b3e5 # v3
77+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@6124774845927d14c601359ab8138699fa5b70c3 # v3
7878
with:
7979
allowlist: |
8080
Open-MSS/

.github/workflows/update-pixi-lockfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
set -o pipefail
2929
pixi update --json | pixi exec pixi-diff-to-markdown >> diff.md
3030
- name: Create or update pull request
31-
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7
31+
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v7
3232
with:
3333
token: ${{ secrets.PAT }}
3434
branch: automation/update-pixi-lockfile/${{ matrix.base_branch }}

docs/conf_sso_test_msscolab.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ When this is the first time you setup a mscolab server, you have to initialize t
103103

104104
.. code:: text
105105
106-
$ mscolab db --init
106+
$ mscolab start
107107
108108
.. note::
109109
An existing database maybe needs a migration, have a look for this on our documentation.

docs/development.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ You can view the default configuration of MSColab in the file `mslib/mscolab/con
171171
If you want to change any values of the configuration, please take a look at the "Configuring Your MSColab Server"
172172
section in :ref:`mscolab`
173173

174-
When using for the first time you need to initialise your database. Use the command :code:`mscolab db --init`
174+
When using for the first time you need to initialise your database. Use the command :code:`mscolab start`
175175
to initialise it. The default database is a sqlite3 database.
176-
You can add some dummy data to your database by using the command :code:`mscolab db --seed`.
177-
The content of the dummy data can be found in the file `mslib/mscolab/seed.py`.
176+
If you want to play around with example data, you can import it using `mscolab db --seed`.
177+
The content of the example data can be found in the file `mslib/mscolab/seed.py`.
178178

179179
To start your server use the command :code:`mscolab start`. This would start the MSColab server on port 8083.
180180
Going to http://localhost:8083/status should now show "MSColab server". This means your server has started successfully.

docs/mscolab.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Make a copy of the above file, rename it to mscolab_auth.py, make the necessary
3030
Steps to Run MSColab Server
3131
---------------------------
3232
- The MSColab server comes included in the MSS python package.
33-
- Once MSS is installed, if you're running the mscolab server for the first time, run the command :code:`mscolab db --init` to initialise your database.
33+
- When you run the MSColab server for the first time after installing MSS, the database is initialized.
3434
- To start the server run :code:`mscolab start`.
3535
- If you ever want to reset or add dummy data to your database you can use the commands :code:`mscolab db --reset` and :code:`mscolab db --seed` respectively.
3636

mslib/msui/flighttrack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
from mslib.utils import thermolib
5353
from mslib.utils.verify_waypoint_data import verify_waypoint_data
5454
from mslib.utils.config import config_loader, save_settings_qsettings, load_settings_qsettings
55-
from mslib.utils.config import MSUIDefaultConfig as mss_default
5655
from mslib.utils.qt import variant_to_string, variant_to_float
5756
from mslib.msui.performance_settings import DEFAULT_PERFORMANCE
5857

@@ -183,7 +182,8 @@ class WaypointsTableModel(QtCore.QAbstractTableModel):
183182
# Signal emitted when a waypoint is moved, inserted or deleted
184183
changeMessageSignal = QtCore.pyqtSignal(str)
185184

186-
def __init__(self, name="", filename=None, waypoints=None, mscolab_mode=False, data_dir=mss_default.mss_dir,
185+
def __init__(self, name="", filename=None, waypoints=None, mscolab_mode=False,
186+
data_dir=config_loader(dataset="mss_dir"),
187187
xml_content=None):
188188
super().__init__()
189189
self.name = name # a name for this flight track

tests/fixtures.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def mscolab_session_server(mscolab_session_app, mscolab_session_managers):
124124
with _running_eventlet_server(mscolab_session_app) as url:
125125
# Wait until the Flask-SocketIO server is ready for connections
126126
sio = socketio.Client()
127-
sio.connect(url, retry=True)
127+
sio.connect(url, retry=True, wait_timeout=60)
128128
sio.disconnect()
129129
del sio
130130
yield url
@@ -186,32 +186,62 @@ def mswms_server(mswms_app):
186186
yield url
187187

188188

189+
def _start_eventlet_server(host, port_queue, app):
190+
"""
191+
Starts the Eventlet server and sends the chosen port back to the parent process.
192+
"""
193+
sock = eventlet.listen((host, 0))
194+
port = sock.getsockname()[1]
195+
port_queue.put(port)
196+
eventlet.wsgi.server(sock, app, log_output=False)
197+
198+
189199
@contextmanager
190200
def _running_eventlet_server(app):
191201
"""Context manager that starts the app in an eventlet server and returns its URL."""
192202
scheme = "http"
193203
host = "127.0.0.1"
194-
socket = eventlet.listen((host, 0))
195-
port = socket.getsockname()[1]
196-
url = f"{scheme}://{host}:{port}"
197-
app.config['URL'] = url
204+
198205
if "fork" not in multiprocessing.get_all_start_methods():
199206
pytest.skip("requires the multiprocessing start_method 'fork', which is unavailable on this system")
207+
200208
ctx = multiprocessing.get_context("fork")
201-
process = ctx.Process(target=eventlet.wsgi.server, args=(socket, app), daemon=True)
209+
# We are using a queue to retrieve the port selected in the child process.
210+
port_queue = ctx.Queue()
211+
212+
process = ctx.Process(target=_start_eventlet_server, args=(host, port_queue, app), daemon=True)
202213
try:
203214
process.start()
215+
# Retrieve the port from the queue
216+
try:
217+
port = port_queue.get(timeout=10)
218+
except multiprocessing.queues.Empty:
219+
raise RuntimeError("Could not retrieve port from server process")
220+
221+
url = f"{scheme}://{host}:{port}"
222+
app.config['URL'] = url
223+
204224
start_time = time.time()
205225
sleep_time = 0.01
206-
while not is_url_response_ok(urllib.parse.urljoin(url, "index")):
207-
if (time.time() - start_time) > 5:
208-
raise RuntimeError(f"Server did not start within 5 seconds at {url}")
226+
time_out = 20
227+
# we check only for the root url, index.html may take longer
228+
readiness_url = urllib.parse.urljoin(url, "/")
229+
while not is_url_response_ok(readiness_url):
230+
if not process.is_alive():
231+
# show the exitcode for further debugging
232+
raise RuntimeError(f"Server process exited early with code {process.exitcode} at {url}")
233+
if (time.time() - start_time) > time_out:
234+
raise RuntimeError(f"Server did not start within {time_out} seconds at {url}")
209235
time.sleep(sleep_time)
210236
sleep_time *= 2
211237
if sleep_time > 1:
212238
sleep_time = 1
213239
yield url
214240
finally:
215241
process.terminate()
216-
process.join(10)
242+
process.join(timeout=10)
243+
if process.is_alive():
244+
# when it is still alive after 10 seconds, kill it
245+
process.kill()
246+
process.join(timeout=5)
217247
process.close()

0 commit comments

Comments
 (0)