Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test instructions for pubcloud engines #1201

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ package/obs/.osc
package/obs/rmt-cli.8.gz
package/obs/_link
package/systemsmanagement:SCC:RMT
repo
registry

vendor/
coverage/
Expand Down
81 changes: 81 additions & 0 deletions engines/instance_verification/TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
## Testing public cloud PAYG client registrations locally

Start RMT with pubcloud engines enabled:

```
bin/rmt-cli products enable sles/15.6/x86_64
bin/rmt-cli mirror product 2609,2626,2683,2618 # mirror SLE 15.6
RMT_LOAD_ENGINES=1 bin/rails s -b 0.0.0.0
```

Run client container:

`docker run --rm -ti --privileged --network=host registry.suse.com/suse/sle15:15.6 /bin/bash`

In the container prepare the needed packages:

```bash
zypper rm -y container-suseconnect
zypper in -y suseconnect vim less curl
zypper in -y http://updates.suse.de/SUSE/Products/SLE-Module-Public-Cloud/15-SP6/x86_64/product/noarch/cloud-regionsrv-client-10.1.7-150000.6.108.1.noarch.rpm
# on SP5: http://updates.suse.de/SUSE/Products/SLE-Module-Public-Cloud/15-SP5/x86_64/product/noarch/cloud-regionsrv-client-10.1.0-150000.6.91.1.noarch.rpm

mv /etc/zypp/repos.d/* /tmp/ # move out BCI repos
```

Patch the `susecloud` zypp resolver to point to the local RMT without relying on a region server. Replace the RESOLVEURL in `/usr/lib/zypp/plugins/urlresolver/susecloud`:

```
def RESOLVEURL(self, headers, body):
repo_url = 'http://172.17.0.1:4224' + headers.get('path')
repo_credentials = headers.get('credentials')
repo_url += '?credentials=' + repo_credentials
self.answer(
'RESOLVEDURL',
{'X-Instance-Data': ''},
repo_url
)
```

Create a test instance_data file: `echo "<instance_data product="SUSE"/>" > /tmp/idata.xml`

Register client in PAYG mode:

`suseconnect --url http://172.17.0.1:4224 --instance-data /tmp/idata.xml`


## Testing public cloud BYOS registrations


Register the client base product by providing a valid registration code:

`suseconnect --url http://172.17.0.1:4224 -r <regcode> --instance-data /tmp/idata.xml`


## Testing public cloud HYBRID registrations


Mirror a non-free extension in RMT:

```
bin/rmt-cli products enable sle-module-live-patching/15.6/x86_64
bin/rmt-cli mirror product 2664 # mirror SLE 15.6
```

Register the client base product with PAYG, then the extension with BYOS:

```
suseconnect --url http://172.17.0.1:4224 --instance-data /tmp/idata.xml
suseconnect --url http://172.17.0.1:4224 -r <regcode> -p sle-module-live-patching/15.6/x86_64 --instance-data /tmp/idata.xml
```

De-register the extension:

`suseconnect --url http://172.17.0.1:4224 -d -p sle-module-live-patching/15.6/x86_64 --instance-data /tmp/idata.xml`


## Notes

* `/usr/lib/zypp/plugins/urlresolver/susecloud` (https://github.com/SUSE-Enceladus/cloud-regionsrv-client) gets the url of the region RMT server and replaces it in the 'susecloud' type zypper services.
* `registercloudguest` logs to /var/log/cloudregister
* Full pubcloud test env: https://confluence.suse.com/pages/viewpage.action?spaceKey=publiccloud&title=Setup+Public+Cloud+Development+Environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# :nocov:
module InstanceVerification
class Application < Rails::Application
config.cache_config_file = Rails.root.join('engines/registry/spec/data/rmt-cache-trim.sh')
config.repo_cache_dir = 'repo/cache'
config.registry_cache_dir = 'registry/cache'
end
end
# :nocov:
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ def validate_instance_data(_instance_data)
end

def parse_instance_data
# :nocov:
if @instance_data.include? '<instance_data/>'
return { 'instance_data' => 'parsed_instance_data', 'example_id' => '1234' } # :nocov:
end

# :nocov:

if @instance_data.include?('SUSE')
if @instance_data.include?('SAP')
return { 'billingProducts' => nil, 'marketplaceProductCodes' => ['6789_SUSE_SAP'] }
return { 'billingProducts' => nil, 'marketplaceProductCodes' => ['6789_SUSE_SAP'], 'example_id' => '1234' }
end

return { 'billingProducts' => ['1234_SUSE_SLES'], 'marketplaceProductCodes' => nil }
return { 'billingProducts' => ['1234_SUSE_SLES'], 'marketplaceProductCodes' => nil, 'example_id' => '1234' }
end
{ 'billingProducts' => ['foo'], 'marketplaceProductCodes' => ['bar'] }
{ 'billingProducts' => ['foo'], 'marketplaceProductCodes' => ['bar'], 'example_id' => '1234' }
end

def payg_billing_code?(iid, identifier)
Expand Down
1 change: 1 addition & 0 deletions engines/scc_proxy/lib/scc_proxy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def announce_system
response = SccProxy.announce_system_scc(auth_header, request.request_parameters)
@system = System.create!(
system_token: SccProxy.instance_id,
scc_system_id: response['id'],
login: response['login'],
password: response['password'],
hostname: params[:hostname],
Expand Down
2 changes: 0 additions & 2 deletions public/repo/.gitignore

This file was deleted.

Loading