Skip to content

Commit 6e01bcd

Browse files
hrideshmgcanihavesomecoffee
authored andcommitted
docs: update installation instructions
1 parent 7a5077b commit 6e01bcd

File tree

5 files changed

+49
-28
lines changed

5 files changed

+49
-28
lines changed

install/ci-vm/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Now, create a service account with sufficient permissions (at least "Google Batc
3636

3737
If you are not the owner of the GCP project you are working on, make sure you have sufficient permissions for creating and managing service accounts; if not, request the project owner for the same.
3838

39-
- Create a service account [here](https://cloud.google.com/storage/docs/creating-buckets)
39+
- Create a service account [here](https://cloud.google.com/iam/docs/service-accounts-create)
4040
- Choose the service account name as per your choice, but at least provide the role of "Google Batch Service Agent" to the account.
4141

4242
You might also want to understand roles in GCP, you can find the official documentation [here](https://cloud.google.com/iam/docs/understanding-roles).

install/installation.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Nginx (Other possible when modifying the sample download section)
66
* Python 3 (Flask and other dependencies)
77
* MySQL
8-
* Pure-FTPD with mysql
8+
* Pure-FTPD with mysql (optional, only needed for FTP file uploads)
99

1010
## Configuring Google Cloud Platform
1111

@@ -40,9 +40,9 @@ For deployment of the platform on a Google Cloud VM instance, one would require
4040
Windows Server 2019 Datacenter
4141
- Boot type disk: Balanced persistent disk
4242
- Size: 50GB
43-
- Choose the service account as the service account you just created for the platform.
44-
- Select the "Allow HTTP traffic" and "Allow HTTPS traffic" checkboxes.
45-
- Navigate to Advanced options -> Networking -> Network Interfaces -> External IPv4 address, and click on Create IP Address and reserve a new static external IP address for the platform.
43+
- Navigate to Security and choose the service account as the service account you just created for the platform.
44+
- Navigate to Network and select the "Allow HTTP traffic" and "Allow HTTPS traffic" checkboxes.
45+
- Under Network Interfaces -> default, reserve a new static external IPv4 address for the platform.
4646

4747
2. Setting up firewall settings
4848

@@ -67,26 +67,27 @@ Windows Server 2019 Datacenter
6767
Clone the latest sample-platform repository from
6868
https://github.com/CCExtractor/sample-platform.
6969
Note that root (or sudo) is required for both installation and running the program.
70-
The `sample-repository` directory needs to be accessible by `www-data`. The
70+
The `sample-platform` directory needs to be accessible by `www-data`, the
7171
recommended directory is thus `/var/www/`.
7272

7373
```
7474
cd /var/www/
7575
sudo git clone https://github.com/CCExtractor/sample-platform.git
7676
```
77+
Place the service account key file that you generated earlier at the root of the sample-platform folder.
7778

78-
### Mounting the bucket
79+
#### Mounting the bucket
7980

8081
Mounting on Linux OS can be done using [Google Cloud Storage FUSE](https://cloud.google.com/storage/docs/gcs-fuse).
8182

8283
Steps:
83-
- Install gcsfuse using [official documentation](https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/installing.md) or using the following script
84+
- Install gcsfuse using [official documentation](https://cloud.google.com/storage/docs/cloud-storage-fuse/install) or using the following script
8485
```
8586
curl -L -O https://github.com/GoogleCloudPlatform/gcsfuse/releases/download/v0.39.2/gcsfuse_0.39.2_amd64.deb
8687
sudo dpkg --install gcsfuse_0.39.2_amd64.deb
8788
rm gcsfuse_0.39.2_amd64.deb
8889
```
89-
- Now, there are multiple ways to mount the bucket, official documentation [here](https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/mounting.md).
90+
- Now, there are multiple ways to mount the bucket, official documentation [here](https://cloud.google.com/storage/docs/cloud-storage-fuse/mount-bucket).
9091
9192
For Ubuntu and derivatives, assuming `/repository` to be the location of samples to be configured, an entry can be added to `/etc/fstab` file, replace _GCS_BUCKET_NAME_ with the name of the bucket created for the platform:
9293
```
@@ -99,32 +100,33 @@ Steps:
99100
sudo mount /repository
100101
```
101102
102-
You may check if the mount was successful and if the bucket is accessible by running `ls /repository` command.
103+
Note that **this directory needs to be accessible by the `www-data` user**, you can verify if the mount was successful by running `sudo -u www-data ls /repository`
103104
104105
#### Troubleshooting: Mounting of Bucket
105106
106107
In case you get "permission denied" for `/repository`, you can check for the following reasons:
107108
1. Check if the service account created has access to the GCS bucket.
108109
2. Check the output of `sudo mount /repository` command.
110+
3. Check the directory permissions for `/repository`
109111
110-
Place the service account key file at the root of the sample-platform folder.
111112
112113
#### MySQL installation
113114
The platform has been tested for MySQL v8.0 and Python 3.7 to 3.9.
114115
115116
It is recommended to install python and MySQL beforehand to avoid any inconvenience. Here is the [installation link](https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-22-04) of MySQL on Ubuntu 22.04.
116117
117-
Next, navigate to the `install` folder and run `install.sh` with root
118+
#### Installing The Platform
119+
Next, navigate to the `install` folder and run `install.sh` with root
118120
permissions.
119121
120122
```
121123
cd sample-platform/install/
122124
sudo ./install.sh
123-
```
125+
```
124126
125127
The `install.sh` will begin downloading and updating all the necessary dependencies. Once done, it'll ask to enter some details in order to set up the sample-platform. After filling in these details, the platform should be ready for use.
126128
127-
Please read the below troubleshooting notes in case of any error or doubt.
129+
When the domain is asked during installation, enter the domain name that will run the platform. E.g., if the platform will run locally, enter `localhost` as the server name.
128130
129131
### Windows
130132
@@ -156,9 +158,6 @@ or platform configuration.**
156158
it's **recommended** to use a valid certificate.
157159
[Let's Encrypt](https://letsencrypt.org/) offers free certificates. For local
158160
testing, a self-signed certificate can be enough.
159-
* When the server name is asked during installation, enter the domain name
160-
that will run the platform. E.g., if the platform will run locally, enter
161-
`localhost` as the server name.
162161
* In case of a `502 Bad Gateway` response, the platform didn't start
163162
correctly. Manually running `bootstrap_gunicorn.py` (as root!) can help to
164163
determine what goes wrong. The snippet below shows how this can be done:
@@ -189,19 +188,27 @@ After the completion of the automated installation of the platform, the followin
189188
- `TestResults/` - Direction containing regression test results
190189
- `vm_data/` - Directory containing test-specific subfolders, each folder containing files required for testing to be passed to the VM instance, test files and CCExtractor build artefact.
191190
192-
Now for tests to run, we need to download the [CCExtractor testsuite](https://github.com/CCExtractor/ccx_testsuite) release file, extract and put it in `TestData/ci-linux` and `TestData/ci-windows` folders.
191+
Now for tests to run, we need to download the [CCExtractor testsuite](https://github.com/CCExtractor/ccx_testsuite) release file, extract and put it in the `TestData/ci-linux` and `TestData/ci-windows` folders.
193192
194-
## GCS configuration to serve file downloads using Signed URLs
193+
You also need to create a shell script named `ccextractortester` and place it in both `ci-linux` and `ci-windows`. This script is meant to launch the testsuite binary, here is what it should look like for Linux:
194+
```sh
195+
#!/bin/bash
196+
exec mono CCExtractorTester.exe "$@"
197+
```
195198

196-
To serve file downloads directly from the private GCS bucket, Signed download URLs have been used.
199+
## Setting up GitHub webhooks
197200

198-
The `serve_file_download` function in the `utility.py` file implements the generation of a signed URL for the file to be downloaded that would expire after a configured time limit (maximum limit: 7 days) and redirects the client to the URL.
201+
Now that the server is running, you can queue new tests either manually (via `/custom/`) or automatically through GitHub Actions.
199202

200-
For more information about Signed URLs, you can refer to the [official documentation](https://cloud.google.com/storage/docs/access-control/signed-urls).
203+
To queue a test whenever a new commit/PR is made, you need to create a GitHub [webhook](https://docs.github.com/en/webhooks/about-webhooks) on the ccextractor repository (or fork of it):
204+
- Set the payload URL to `https://<your_domain>/start-ci`
205+
- Set the content type to JSON.
206+
- Enter the same secret that you used during installation (`GITHUB_CI_KEY`)
207+
- Select the Push, PR and Issue events as triggers.
201208

202209
## Setting up cron job to run tests
203210

204-
Now the server being running, new tests would be queued and therefore a cron job is to be setup to run those tests.
211+
To run the new tests that are being queued up, a cron job is required.
205212
The file `mod_ci/cron.py` is to be run in periodic intervals. To setup a cron job follow the steps below:
206213
1. Open your terminal and enter the command `sudo crontab -e`.
207214
2. To setup a cron job that runs this file every 10 minutes, append this at the bottom of the file
@@ -210,6 +217,14 @@ The file `mod_ci/cron.py` is to be run in periodic intervals. To setup a cron jo
210217
```
211218
Change the `/var/www/sample-plaform` directory, if you have installed the platform in a different directory.
212219
220+
## GCS configuration to serve file downloads using Signed URLs
221+
222+
To serve file downloads directly from the private GCS bucket, Signed download URLs have been used.
223+
224+
The `serve_file_download` function in the `utility.py` file implements the generation of a signed URL for the file to be downloaded that would expire after a configured time limit (maximum limit: 7 days) and redirects the client to the URL.
225+
226+
For more information about Signed URLs, you can refer to the [official documentation](https://cloud.google.com/storage/docs/access-control/signed-urls).
227+
213228
## File upload size for HTTP
214229
215230
In order to accept big files through HTTP uploads, some files need to be

install/sample_db.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def run():
1919
from mod_test.models import Test
2020
from mod_upload.models import Upload
2121

22-
2322
db = create_session(sys.argv[1])
2423

2524
entries = []

mod_ci/controllers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,14 @@ def progress_type_request(log, test, test_id, request) -> bool:
13481348

13491349
for p in times:
13501350
parts = p.time.split(',')
1351-
start = datetime.datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S')
1352-
end = datetime.datetime.strptime(parts[-1], '%Y-%m-%d %H:%M:%S')
1351+
try:
1352+
# Try parsing with microsecond precision first
1353+
start = datetime.datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f')
1354+
end = datetime.datetime.strptime(parts[-1], '%Y-%m-%d %H:%M:%S.%f')
1355+
except ValueError:
1356+
# Fall back to format without microseconds
1357+
start = datetime.datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S')
1358+
end = datetime.datetime.strptime(parts[-1], '%Y-%m-%d %H:%M:%S')
13531359
total_time += int((end - start).total_seconds())
13541360

13551361
if len(times) != 0:

mod_test/controllers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def get_data_for_test(test, title=None) -> Dict[str, Any]:
150150
prep_average_key = 'avg_prep_time_' + test.platform.value
151151
average_prep_time = int(float(GeneralData.query.filter(GeneralData.key == prep_average_key).first().value))
152152

153-
test_progress_last_entry = g.db.query(func.max(TestProgress.test_id)).first() or 0
153+
test_progress_last_entry = g.db.query(func.max(TestProgress.test_id)).first()
154+
last_test_id = test_progress_last_entry[0] if test_progress_last_entry is not None else 0
154155
queued_gcp_instance = g.db.query(GcpInstance.test_id).filter(GcpInstance.test_id < test.id).subquery()
155156
queued_gcp_instance_entries = g.db.query(Test.id).filter(
156157
and_(Test.id.in_(queued_gcp_instance), Test.platform == test.platform)
@@ -159,7 +160,7 @@ def get_data_for_test(test, title=None) -> Dict[str, Any]:
159160
TestProgress.timestamp))).filter(TestProgress.test_id.in_(queued_gcp_instance_entries)).group_by(
160161
TestProgress.test_id).all()
161162
number_gcp_instance_test = g.db.query(Test.id).filter(
162-
and_(Test.id > test_progress_last_entry[0], Test.id < test.id, Test.platform == test.platform)
163+
and_(Test.id > last_test_id, Test.id < test.id, Test.platform == test.platform)
163164
).count()
164165
average_duration = float(GeneralData.query.filter(GeneralData.key == var_average).first().value)
165166
queued_tests = number_gcp_instance_test

0 commit comments

Comments
 (0)