/srv/irclogs.ubuntu.com/2020/10/01/#smooth-operator.txt

Chipacawelcome to day 1 post-Quino08:59
bthomasQuino ?08:59
Chipacabthomas: https://en.wikipedia.org/wiki/Quino09:03
Chipacabthomas: https://i.imgur.com/wDlx65Z.jpg09:08
bthomasthanks09:09
Chipacabthomas: or maybe https://i.imgur.com/MvUSF2A.jpg09:10
bthomasnice and deep09:11
Chipacahis best ones were like that imho09:11
Chipacaalthough not all, eg https://pbs.twimg.com/media/C-WT7p-W0AAs8tl?format=jpg&name=medium09:11
Chipaca(there is social commentary in there, but it's not the joke)09:12
bthomas:) I like dilbert a lot09:13
bthomasBTW there is a comic book mode for emacs09:13
bthomasof course there is :)09:13
Chipacaof COURSE there is :-p09:13
Chipacahehe09:13
aluriaChipaca: thx for the heads-up, yesterday re: charm-gitlab-k8s use of "self" as self.on_database_lost. I think I now have a clear idea on how to work with relations and events (+custom events)09:35
alurianow, I'm trying to create a simple test https://pastebin.ubuntu.com/p/5Dm35vNVxk/09:36
Chipacaaluria: FWIW, if you're not creating an interface, custom events should not be on your radar at all09:36
aluriabut I get "AttributeError: 'Unit' object has no attribute 'framework'" because of the use of self.model.unit as "charm" attribute09:36
aluriaChipaca: yep, understood re: custom events (and I'm creating a interface-vpn one to be used on 2 different charms (one using the requires side, and the other one the provides one)09:37
Chipacanice09:37
aluriathe previous pastebin also should have a method on the VPNProvides class that uses self.model -> https://pastebin.ubuntu.com/p/f9Byk5SFRB/09:38
aluriahow should I mock the "self.model" from the VPNProvides class using the harness capabilities?09:39
Chipacaaluria: er09:39
aluriaI know VPNProvides.model = self.harness.model can't be done because it is immutable09:39
Chipacaaluria: you're doing VPNProvides(self.model.unit, 'vpn')09:40
Chipacaaluria: but VPNPRovides' first argument is called 'charm'09:40
Chipacanot 'unit'09:40
Chipacaaluria: and it looks like it should be a charm, indeed, not a unit :)09:41
Chipacaaluria: so you want harness.charm09:41
Chipacawhich will only be not-None after you've done harness.begin09:41
aluriaChipaca: ah, cheers - I also see an example here -> https://github.com/openstack-charmers/ops-openstack/blob/ea51b43ec2a714aab3202d071d50a98cb7a4522d/unit_tests/test_ops_openstack.py#L7709:44
aluriaty09:44
aluriaChipaca: can an interface class inherit from CharmBase instead of Object?14:07
aluriasomething like ClassName(self.harness.charm, relation_name) <-- works, but ops.testing.Harness(ClassName) fails because: ops/testing.py", line 136, in begin -> self._charm = TestCharm(self._framework) -> TypeError: __init__() missing 1 required positional argument: 'relation_name'14:09
Chipacaaluria: i don't think you want your interface to be a charm, no14:10
Chipacaaluria: but, in your tests, you can create a charm that uses the interface14:10
alurianop14:10
aluriaaaah, ok14:10
aluriaI'll try that, ty14:11
aluriaChipaca: that worked for general methods of the interface class, ty - last Q of the day is that I have an on_relation_joined(self, event) method which has -> event.relation.data[self.model.unit]["ip"] = value <-- and I want to check if the value has correctly been shared14:40
aluriain the setUp method, I've done -> self.relation_id_vpn = self.harness.add_relation("vpn", "vpn-client"); self.harness.begin()14:40
aluriaand on the test case, I've done -> self.harness.add_relation_unit(self.relation_id_vpn, "vpn-client/0")14:40
aluriahowever, rel_data = self.harness.get_relation_data(self.relation_id_vpn, "vpn-client/0") <-- returns an empty dict14:41
Chipacaaluria: shouldn't that be vpn/0?14:46
aluriavpn is the interface name, and vpn-client is the appname (hence, vpn-client/0 for the unit name)14:47
Chipacaaluria: but what's the name of the other side of the relation?14:47
Chipacait's that data that you're setting, aiui14:48
aluriaok, so I was trying to test the VPNProvides class, and the later do the same for a VPNRequires class... for the on_relation_joined part, should I test both classes together?14:49
aluria*then14:49
Chipacayou lost me :)14:49
Chipacaaluria: in that test, what is self.harness.unit.name ?14:50
aluriaself.assertEqual(self.harness.unit.name, "asdf") -> AttributeError: 'Harness' object has no attribute 'unit'14:51
Chipacaaluria: self.harness.model.unit sorry14:52
Chipaca...name14:52
aluriamyapp/0 <-- b/c in the Harness call, I set up a meta value where "name: myapp"14:53
Chipacaaluria: and what's in self.harness.get_relation_data(self.relation_id_vpn, self.harness.model.unit.name) ?14:53
aluriayeah, I just tested that and it returns what it should14:53
Chipaca:)14:53
aluriaI was not understanding which unit name or app name to use14:54
Chipacayeah, it takes some mind-melding14:54
aluriaI thought the ones in self.harness.add_relation and add_relation_unit were used14:54
Chipacai still need to think really slowly through it14:54
Chipaca(in my defense, i'm new to juju)14:54
aluriathx Chipaca - I think I have minimum tests running for the VPNProvides interface - I'll work on the requires part but don't expect to interrupt you (at least, today :)14:55
Chipacai might ignore you preƫmptively14:55
Chipaca(got meetings coming up)14:55
Chipacawhich reminds me, bthomas, justinclark, [dylan], you're going to be all lonesome during standup (conflicting meeting)14:56
* bthomas is already feeling lonesome14:56
justinclark:(14:56
dstathisI have a couple questions about relation related hooks in operator15:13
dstathisfor the event argument of relation_changed, what is event.unit? Is it a unit from the application you are related to?15:15
dstathisIf so, why do I always see people checking if event.unit is None? What would be the case where this is true?15:15
justinclarkdstathis yes, event.unit is the unit from the application you're related to. My understanding is that this can be None if the relation is broken and the remote unit is no longer available15:19
dstathisI actually found "The remote unit that has triggered this event. This may be None if the relation event was triggered as an Application level event"15:20
justinclarkInteresting. Now I'm curious if a broken relation would also lead to event.unit being None or I was misunderstanding the use for that.15:21

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!